A new kind of BPM with Activiti

4,608 views
4,426 views

Published on

This session will demonstrate the Activiti tools in the context of the full software development cycle. Starting from business people over developers to system administrators. Activiti facilitates the collaboration between those roles in a pragmatic and new way. For the developer part, we'll briefly dive a bit deeper. With code samples we'll give you a look under the hood.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,608
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
220
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

A new kind of BPM with Activiti

  1. 1. A new kind of BPM with Activiti<br />2<br />Tom Baeyens & Joram Barrez<br />Alfresco<br />twitter: @tombaeyens @jbarrez<br />
  2. 2. Tom Baeyens<br />3<br /><ul><li>Founder of Activiti & jBPM
  3. 3. Passionate about Java and BPM
  4. 4. http://processdevelopments.blogspot.com/</li></ul>Joram Barrez<br /><ul><li>Ex-core developer JBossjBPM
  5. 5. Core developer Activiti
  6. 6. http://www.jorambarrez.be/</li></li></ul><li>BPM for developers<br />4<br /><ul><li>Process = Activities + Transitions
  7. 7. Activity = Execution step in your application
  8. 8. Configure out of the box activity types
  9. 9. User task
  10. 10. Email
  11. 11. Script
  12. 12. Web service
  13. 13. JMS
  14. 14. EJB
  15. 15. Delegate to Java& scripting where necessary
  16. 16. Timers</li></li></ul><li>Activiti Engine<br />5<br /><ul><li>Essence: State machine
  17. 17. Persist state of an execution flow</li></ul>Execution<br />EmplJohn Doe<br />Date 5/10/2010<br />Doc vacation.xls<br />State Approved<br />
  18. 18. Transactional Control Flow<br />6<br /><ul><li>Start process instance
  19. 19. Create new execution
  20. 20. Pass initial data in (optional)
  21. 21. Take transition to “Fetch data from DB”
  22. 22. Execute “Fetch data from DB”
  23. 23. Take transition to “Wait 1”
  24. 24. Stop interpreting process
  25. 25. Persist state
  26. 26. Return</li></ul>Execution<br />
  27. 27. Transactional Control Flow<br />7<br />INSERT INTO ACT_RU_EXECUTION (…, ACTIVITY_ID_, …) <br />values <br />(…, ‘Wait’, …) <br />Execution<br />
  28. 28. Transactional Control Flow<br />8<br /><ul><li>Signal
  29. 29. Load existing execution
  30. 30. Pass data in (optional)
  31. 31. Take transition to “Wait 2”
  32. 32. Stop interpreting process
  33. 33. Update runtime execution
  34. 34. Return</li></ul>Execution<br />
  35. 35. Transactional Control Flow<br />9<br />UPDATE ACT_RU_EXECUTION SET ACTIVITY_ID = ‘Wait 2’ <br />Execution<br />
  36. 36. Transactional Control Flow<br />10<br /><ul><li>Signal
  37. 37. Load existing execution
  38. 38. Pass data in (optional)
  39. 39. Take transition to “Send email”
  40. 40. Execute “Send email”
  41. 41. Take transition to “end”
  42. 42. Stop interpreting process
  43. 43. Delete runtime execution
  44. 44. Return</li></ul>Execution<br />
  45. 45. Transactional Control Flow<br />11<br />DELETE FROM ACT_RU_EXECUTION WHERE ID_ = ?<br />Execution<br />
  46. 46. Extra convenience in activity types<br />12<br /><ul><li>Examples
  47. 47. Task lists
  48. 48. JMS message send & receive
  49. 49. Web service send & receive
  50. 50. And… everything you can do in Java
  51. 51. Activity pluggability</li></li></ul><li>Extra convenience in history<br />13<br /><ul><li>Optional, default turned on
  52. 52. Log every process instance and activity instance
  53. 53. Activities at business level
  54. 54. Statistics are valuable business intelligence
  55. 55. For FREE</li></li></ul><li>Coming up<br />14<br /><ul><li>How to implement a process with Activiti
  56. 56. Showing you the nitty-gritty details
  57. 57. Making you an Activiti-ninja-developer-hero</li></li></ul><li>Demo<br />15<br /><ul><li>Use case: banks shouldn’t lend money to just anybody
  58. 58. Thorough analysis is needed
  59. 59. All steps needs to be recorded in official documents
  60. 60. Decisions are done based on Excel decision tables</li></li></ul><li>The mortgage process<br />16<br />
  61. 61. The mortgage process<br />17<br />= CMIS call <br />
  62. 62. Deployment<br />18<br /><ul><li>Collection of resources</li></ul>Deployment deployment = repositoryService<br /> .createDeployment()<br /> .addClasspathResource(“mortgage-process.bpmn20.xml”)<br /> .addInputStream(“mortgage.png”)<br /> .addZipInputStream(“mortgage-docs.zip”)<br /> …<br />Deployment<br />
  63. 63. Deployment<br />19<br /><ul><li>“Deploying”</li></ul>repositoryService<br /> .createDeployment()<br /> .addXXX()<br /> …<br /> .deploy()<br />bytes<br />Activiti engine<br />Mortgage process<br />bpmn<br />Deployment<br />deployers<br />ProcessDefinition<br />
  64. 64. Process versioning<br />20<br /><ul><li>Markets, customers, products, … change
  65. 65. Business processes change
  66. 66. Activiti supports versioned process definitions</li></ul>ProcessInstanceprocessInstanceA = <br />runtimeService.startProcessInstanceByKey(“mortgage”);<br />repositoryService.createDeployment()<br /> .addClasspathResource(“mortgage-process.bpmn20.xml”)<br /> .deploy();<br />Process def “mortgage”, version = 1<br />ProcessInstanceprocessInstanceB = <br />runtimeService.startProcessInstanceByKey(“mortgage”);<br />Process def “mortgage”, version = 2<br />
  67. 67. Process versioning<br />21<br /><ul><li>But what about existingprocess instances?
  68. 68. They execute according the original process definition
  69. 69. “Phase-out” strategy
  70. 70. New process instances
  71. 71. Default: latest deployed process definition
  72. 72. Instance migration</li></ul>runtimeService.startProcessInstanceByKey(“process-key”);<br />ProcessDefinitionprocDef = <br />repositoryService.createProcessDefinitionQuery()<br /> .name(“myProcess”)<br /> .version(2)<br /> .singleResult();<br />runtimeService.startProcessInstanceById(procDef.getId());<br />Latest deployed<br />Specific version<br />
  73. 73. Starting the process<br />22<br /><ul><li>Programmatically</li></ul>BPMN start event<br />ProcessInstanceprocessInstanceA = <br />runtimeService.startProcessInstanceByKey(“myProces”);<br />
  74. 74. Start form<br />23<br /><ul><li>Processes often need data to run
  75. 75. Start event can have a start form to capture this data
  76. 76. Activiti Explorer</li></ul>FormInstance form = repositoryService.getStartFormInstance(“mortgage”);<br />
  77. 77. Start form<br />24<br /><ul><li>Activiti Explorer
  78. 78. Supports easy-to-build-and-understand HTML forms</li></li></ul><li>User task<br />25<br /><ul><li>Wait state
  79. 79. Creates a Task entry in the DB</li></li></ul><li>Service task<br />26<br /><ul><li>Call custom business logic
  80. 80. Support for
  81. 81. Delegation to class
  82. 82. Expressions (see later)</li></li></ul><li>Service task<br />27<br /><ul><li>Soon
  83. 83. Webservice support</li></li></ul><li>Exclusive gateway<br />28<br /><ul><li>Control flow
  84. 84. Selects 1 (and only 1) outgoing seq-flow based on the expressions</li></li></ul><li>Mail task<br /><ul><li>Automatic step
  85. 85. Specific service task shipped with Activiti</li></ul>29<br />
  86. 86. Unit testing your business processes<br /><ul><li>With Activiti, your business processes are an integral part of your software project
  87. 87. So they should be tested just the same as your regular application code …
  88. 88. With unit tests !
  89. 89. Activiti supports both JUnit 3 and JUnit4 style of testing your business processes
  90. 90. And ships with a lot of convience for testing
  91. 91. Demo</li></ul>30<br />Pic from http://silverbackapp.com<br />
  92. 92. The cool stuff<br /><ul><li>That didn’t make it into the demo
  93. 93. But is just too cool not to share with you
  94. 94. Timers
  95. 95. Script support
  96. 96. Query API
  97. 97. Spring integration
  98. 98. Method expressions
  99. 99. JPA</li></ul>31<br />
  100. 100. Timers<br /><ul><li>Work is often time constrained
  101. 101. A timer boundary event can be attached</li></ul> to the boundary of any task or subprocess<br />32<br />
  102. 102. Timers<br /><ul><li>When timer fires
  103. 103. Current execution(s) inside scope of event are destroyed and process continues following seq-flow going out the timer event</li></ul>33<br />
  104. 104. Script task<br /><ul><li>Execute a script embedded in the process definition
  105. 105. Any JSR-223 compliant script language
  106. 106. Opens up powerful capabilities
  107. 107. Javascript, XPath, CMIS-script (?) </li></ul><scriptTask id="theScriptTask" name="Execute script" scriptFormat="groovy">  <script>    sum = 0    for (i in inputArray) {      sum += i    }<br />execution.setVariable(“myVar”, sum)  </script></scriptTask><br />34<br />
  108. 108. Query API<br /><ul><li>No need to learn the intern data model
  109. 109. Powerful and uniform query API
  110. 110. Deployments and process definitions
  111. 111. Process instances and executions
  112. 112. History
  113. 113. Variables
  114. 114. Tasks, jobs, users, groups, historic activities/process instances/variables, …</li></ul>repositoryService.createProcessDefinitionQuery.keyLike(“%mortgage%”).latest();<br />runtimeService.createProcessInstanceQuery<br />.processDefinitionKey(“mortgage-process)”.orderByProcessInstanceId().desc();<br />historyService.createHistoricActivityQuery().processDefinitionId(procDefId)<br /> .activityType(“userTask”).orderByDuration().asc();<br />runtimeService.createProcessInstanceQuery()<br /> .variableValueGreaterThan(“amount”, 50000);<br />35<br />
  115. 115. Spring integration<br /><ul><li>First-class integration with Spring
  116. 116. Define and inject Activiti process engine and services
  117. 117. Leverage and integrate with Spring transaction management
  118. 118. Delegate to Spring beans in the process definition
  119. 119. Resource deployment and duplicate filtering for simplified development
  120. 120. Spring unit testing support</li></ul>36<br />
  121. 121. Spring integration<br /><ul><li>ProcessEngine as a Spring bean
  122. 122. Delegate to Spring beans</li></ul><bean id=“printer” …<br />37<br />
  123. 123. Method expressions and JPA<br /><ul><li>Besides the typical expressions that everyone supports, Activiti has
  124. 124. method expressions
  125. 125. method parameters
  126. 126. Variables, execution, …
  127. 127. First-class JPA support
  128. 128. Store JPA entity as process variable
  129. 129. Seamless integration of domain model with process
  130. 130. Only domain model reference is stored
  131. 131. Fetch/update is done in original data store</li></ul>38<br />
  132. 132. Throwing it all together<br />Update JPA entity<br />Decision based on <br />JPA entity property<br />Spring bean<br />Process variables<br />39<br />
  133. 133. The Activiti Experience<br /><ul><li>Satisfy your Activiti itch
  134. 134. One-stop-shop download:
  135. 135. http://www.activiti.org
  136. 136. Demo: “The Activiti Experience”
  137. 137. Do you have an excuse for not trying out Activiti later today?</li></ul>40<br />

×