2. • Founder of Activiti & jBPM
• Passionate about Java and BPM
• http://processdevelopments.blogspot.com/
• Ex-core developer JBossjBPM
• Core developer Activiti
• http://www.jorambarrez.be/
3
3. • Process = Activities + Transitions
• Activity = Execution step in your application
• Configure out of the box activity types
• User task
• Email
• Script
• Web service
• JMS
• EJB
• Delegate to Java
& scripting where
necessary
• Timers
4
4. • Essence: State machine
• Persist state of an execution flow
Execution
EmplJohn Doe
Date 5/10/2010
Doc vacation.xls
State Approved
5
5. • Start process instance
• Create new execution
• Pass initial data in (optional)
• Take transition to “Fetch data from DB”
• Execute “Fetch data from DB”
• Take transition to “Wait 1”
• Stop interpreting process
• Persist state
Execution
• Return
6
7. • Signal
• Load existing execution
• Pass data in (optional)
• Take transition to “Wait 2”
• Stop interpreting process
• Update runtime execution
• Return
Execution
8
9. • Signal
• Load existing execution
• Pass data in (optional)
• Take transition to “Send email”
• Execute “Send email”
• Take transition to “end”
• Stop interpreting process
• Delete runtime execution
Execution
• Return
10
10. DELETE FROM
ACT_RU_EXECUTION WHERE ID_ =
?
Execution
11
11. • Examples
• Task lists
• JMS message send & receive
• Web service send & receive
• And… everything you can do in Java
• Activity pluggability
12
12. • Optional, default turned on
• Log every process instance
and activity instance
• Activities at business level
Statistics are valuable
business intelligence
For FREE
13
13. • How to implement a process with Activiti
• Showing you the nitty-gritty details
• Making you an Activiti-ninja-developer-hero
14
14. • Use case: banks shouldn‟t lend money to just anybody
• Thorough analysis is needed
• All steps needs to be recorded in official documents
• Decisions are done based on Excel decision tables
15
19. • Markets, customers, products, … change
• Business processes change
• Activiti supports versioned process definitions
ProcessInstanceprocessInstanceA =
runtimeService.startProcessInstanceByKey(“mortgage”);
repositoryService.createDeployment()
Process def .addClasspathResource(“mortgage-process.bpmn20.xml”)
“mortgage”, ver
sion = 1 .deploy();
ProcessInstanceprocessInstanceB =
Process def runtimeService.startProcessInstanceByKey(“mortgage”);
“mortgage”, ver
sion = 2
20
20. • But what about existingprocess instances?
• They execute according the original process definition
• “Phase-out” strategy
• New process instances
• Default: latest deployed process definition
• Instance migration
runtimeService.startProcessInstanceByKey(“process-key”);
Latest deployed
ProcessDefinitionprocDef =
repositoryService.createProcessDefinitionQuery()
.name(“myProcess”)
.version(2)
.singleResult();
runtimeService.startProcessInstanceById(procDef.getId());
21 Specific version
22. • Processes often need data to run
• Start event can have a start form to capture this data
FormInstance form = repositoryService.getStartFormInstance(“mortgage”);
• Activiti Explorer
23
27. • Control flow
• Selects 1 (and only 1) outgoing seq-flow
based on the expressions
28
28. • Automatic step
• Specific service task shipped with Activiti
29
29. • With Activiti, your business processes are an integral
part of your software project
• So they should be tested just the same as your regular
application code …
• With unit tests !
• Activiti supports both JUnit 3 and JUnit4 style of testing
your business processes
• And ships with a lot of convience for testing
• Demo
30
Pic from http://silverbackapp.com
30. • That didn‟t make it into the demo
• But is just too cool not to share with you
• Timers
• Script support
• Query API
• Spring integration
• Method expressions
• JPA
31
31. • Work is often time constrained
• A timer boundary event can be attached
to the boundary of any task or subprocess
32
32. • When timer fires
• Current execution(s) inside scope of event are
destroyed and process continues following seq-flow
going out the timer event
33
33. • Execute a script embedded in the process definition
• Any JSR-223 compliant script language
• Opens up powerful capabilities
• Javascript, XPath, CMIS-script (?)
<scriptTask id="theScriptTask" name="Execute script" scriptFormat="groovy">
<script>
sum = 0
for (i in inputArray) {
sum += i
}
execution.setVariable(“myVar”, sum)
</script>
</scriptTask>
34
34. • No need to learn the intern data model
• Powerful and uniform query API
• Deployments and process definitions
repositoryService.createProcessDefinitionQuery.keyLike(“%mortgage%”).latest();
• Process instances and executions
runtimeService.createProcessInstanceQuery
.processDefinitionKey(“mortgage-process)”.orderByProcessInstanceId().desc();
• History
historyService.createHistoricActivityQuery().processDefinitionId(procDefId)
.activityType(“userTask”).orderByDuration().asc();
• Variables
runtimeService.createProcessInstanceQuery()
.variableValueGreaterThan(“amount”, 50000);
• Tasks, jobs, users, groups, historic activities/process
instances/variables, …
35
35. • First-class integration with Spring
• Define and inject Activiti process engine and services
• Leverage and integrate with Spring transaction
management
• Delegate to Spring beans in the process definition
• Resource deployment and duplicate filtering for
simplified development
• Spring unit testing support
36
36. • ProcessEngine as a Spring bean
• Delegate to Spring beans
<bean id=“printer” …
37
37. • Besides the typical expressions that everyone
supports, Activiti has
• method expressions
• method parameters
• Variables, execution, …
• First-class JPA support
• Store JPA entity as process variable
• Seamless integration of domain model with process
• Only domain model reference is stored
• Fetch/update is done in original data store
38
38. Update JPA entity Decision based on
Spring bean JPA entity property
Process variables
39
39. • Satisfy your Activiti itch
• One-stop-shop download:
• http://www.activiti.org
• Demo: “The Activiti Experience”
• Do you have an excuse for not
trying out Activiti later today?
40