jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On

on

  • 9,920 views

This module is about start using jBPM5 and the things that you need to know in order to understand the basic concepts about how it works. During this module you can download and play with a sample ...

This module is about start using jBPM5 and the things that you need to know in order to understand the basic concepts about how it works. During this module you can download and play with a sample project that define a simple business process with some business rules. This module provides different tests that shows how to interact with our processes in different ways and how to test the behavior unit testing them. For more information check out: http://salaboy.wordpress.com/

Statistics

Views

Total Views
9,920
Views on SlideShare
6,069
Embed Views
3,851

Actions

Likes
4
Downloads
398
Comments
0

10 Embeds 3,851

http://salaboy.com 3062
http://salaboy.wordpress.com 751
http://srvpsat.gpm.int 16
url_unknown 12
http://static.slideshare.net 3
http://unesrproyectounoieccaempro.blogspot.com 2
http://webcache.googleusercontent.com 2
http://www.plugtree.com 1
http://translate.googleusercontent.com 1
http://172.18.10.148 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

jBPM5 Community Training Module 4: jBPM5 APIs Overview + Hands On Presentation Transcript

  • 1.    jBPM5 Community Training Sponsored by Plugtree
  • 2. Module 4: jBPM5 APIs Overview and Hands On jBPM5 Community Training version: 1.0-SNAPSHOT Release Date: 01/28/2011 Under The Creative Common License
  • 3. Module 2: BPM DisciplinejBPM5 Community Training Course byMauricio "Salaboy" Salatino is licensedunder a Creative Commons Attribution 3.0 Unported License.Based on a work at salaboy.wordpress. com. Permissions beyond the scope of this license may be available at http: //salaboy.wordpress.com/.
  • 4. AgendajBPM5 API Overview Basic Concepts and Components Knowledge Builder Knowledge Base Knowledge SessionHands On Labs Downloading the Source Code Loading the Source Code in you IDE Sample Use Case Exercise
  • 5. jBPM5 Quick OverviewWhat is jBPM5? Its a Business Process Engine It execute our business process definitions (BPMN2) It can be easily embedded as your application dependency or be used as a separated services It will be responsible to handle the interaction between Human and Systems defined inside our business processes Its developer and business analyst orientedWhat is not jBPM5? Its not a process designer Its not a monolithic server Its not a final end user tool
  • 6. jBPM5 Components Overview
  • 7. jBPM5 Components OverviewjBPM5 Ecosystem jBPM5 Runtime BPMN2 Semantic Module Core Business Process Engine Persistence and Transaction Mechanism History Logs jBPM5 Human Task Server jBPM5 Tooling jBPM5 Designer jBPM5 Process Console jBPM5 REST Process Server jBPM5 BAM
  • 8. jBPM5 Runtime jBPM Runtime BPMN2 Semantic Module: it understand BPMN2 process definitions and let us load our process definitions into the jBPM5 Runtime.Core Business Process Engine: it runs our ProcessDefinitions. It provide us a full set of APIs to interact and createour process instances. Persistence and Transaction Mechanism: it helps us to store the runtime status of our running processes History Logs: it stores all the activity that its being executed in the engine.
  • 9. jBPM5 Human Task ServerjBPM5 Human Task Server Pluggeable component to handle the human tasks life cycle Implements the Web Service Human Task specification - > http://incubator.apache.org/hise/WS- HumanTask_v1.pdf It defines the data structures to store information about the Human Tasks involved in our processes, without knowing about the process itself It defines the different states that a human task can have during the interaction
  • 10. jBPM5 Human Task ServerjBPM5 Tooling jBPM5 Designer: Graphical Process Designer that lets us define BPMN2 compliant business processes. jBPM5 Process Console: It let us test and run our processes, providing us a runtime environment where we can interact with them. jBPM5 REST Process Server: It exposes the jBPM5 runtime through a REST interface to be able to interact with the runtime from different clients and programming languages. jBPM5 BAM: It provides us some widgets and reporting features to externalize, browse and aggregate information that its being generated from the processes execution.
  • 11. jBPM5 Source Code jBPM5 Source Code -> http://www.github.com/krisv/jbpm Get the code and build it! git clone https://github.com/krisv/jbpm.git mvn clean install
  • 12. jBPM5 Hands onjBPM5 Hands On Get the Example Projects Code (the first time): git clone https://github. com/Salaboy/JBPM5-Training-Examples Update the Example Projects: git pull (inside the git local copy)
  • 13. 01-jBPM5-SimpleEmergencyServiceProcessSimple Emergency Service Process Go inside the project directory and build it with: mvn clean install Open it with your favorite IDE If you are used to Eclipse you will have plugins available to work with BPMN2 processes. Make sure you have the Maven plugins installed If you use IntelliJ I recommned you to install the Drools Plugins (No support for BPMN2 yet) If you use Netbeans be sure to have JUnit plugins installed Open the Test Class: SimpleEmergencyProcessTest
  • 14. SimpleEmergencyProcessTestSimple Emergency Service Test We will be working with the process definition located at: src/test/resources/EmergencyServiceSimp le.bpmn And also with the rules file located at: src/test/resources/SelectEmergencyVehic leSimple.drl The test file contains 4 tests that show different types of interaction We will analyze each of the tests and compares the differences between them We will analyze the process and the rules files in order to understand the use cases and the results that we are looking for the tests
  • 15. The Business ProcessEmergencyServiceSimple.bpmn
  • 16. The Business ProcessEmergencyServiceSimple.bpmn<definitions> <process processType="Private" isExecutable="true" id="SimpleEmergencyService" name="Emergency Service Main Process"> <startEvent id="_1" name="StartProcess"/> <userTask id="_2" name="Ask for Emergency Information"> <ioSpecification> ... </ioSpecification> <dataInputAssociation> ... </dataInputAssociation> <dataOutputAssociation> ... </dataOutputAssociation> <potentialOwner> <resourceAssignmentExpression> <formalExpression>operator</formalExpression> </resourceAssignmentExpression> </potentialOwner> </userTask> <businessRuleTask id="_3" name="Select Vehicle" g:ruleFlowGroup="select_vehicle"/>
  • 17. The Business ProcessEmergencyServiceSimple.bpmn (cont) <userTask id="_4" name="Dispatch Vehicle"> ... </userTask> <scriptTask id="_5" name="Report" scriptFormat="http://www.java.com/java"> <script> </script> </scriptTask> <endEvent id="_6" name="EndProcess"> <terminateEventDefinition/> </endEvent>
  • 18. The Business ProcessEmergencyServiceSimple.bpmn (connections) <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2"/> <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3"/> <sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4"/> <sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5"/> <sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6"/> </process></definitions>
  • 19. The Business RulesSelectEmergencyVehicle.drl rule "New Ambulance for Heart Attack Emergencies" ruleflow-group "select_vehicle" when $process: WorkflowProcessInstance() Emergency(type == "Heart Attack") from $process.getVariable("emergency") then System.out.println("A new Ambuance is being created!"); Ambulance ambulance = new Ambulance("MyAmbulance"); $process.setVariable("vehicle", ambulance); insert(ambulance); end
  • 20. The Business RulesSelectEmergencyVehicle.drl (cont.) rule "New Fire Truck for Fire Emergencies" ruleflow-group "select_vehicle" when $process: WorkflowProcessInstance() Emergency(type == "Fire") from $process.getVariable("emergency") then System.out.println("A new FireTruck is being created!"); FireTruck fireTruck = new FireTruck("MyFireTruck"); $process.setVariable("vehicle", fireTruck); insert(fireTruck); end
  • 21. 1st Test: automaticHumanTasksTest()Automatic Human Tasks Test It creates a basic interaction with our business process It load the process file using the KnowledgeBuilder It creates the Knowledge Base and add the Knowledge Packages from the Knowledge Builder It creates a Stateful Knowledge Session using the Knowledge Base It simulates the human interaction with a dumb work item definition to simplify the test (MyAutomaticHumanSimulatorWorkItemHandler) It Start the process Because the Human Interactions are simulated and automatically completed by the custom work item we can check that the process is completed after calling the startProcess() method
  • 22. 2nd Test: nonAutomaticHumanTasksTest()Non Automatic Human Tasks Test It creates a basic interaction with our business process It attaches a work item handler to simulate non automatic human interactions (MyNonAutomaticHumanSimulatorWorkItemHandler) After we start the process we need to complete the Human Interactions We can complete the Mock Implementation using the completeWorkItem() method that the attached work item handler provides After we complete the first Human Interaction we need to call the fireAllRules() method in order to continue the process execution Because we dont have rules in this test this doesnt make any sense, be patient for the last test
  • 23. 3rd Test: inputDataTest()Input Data Test It creates a basic interaction with our business process It attaches a work item handler to simulate non automatic human interactions, but this time the work item changes some values (MyHumanChangingValuesSimulatorWorkItemHandler ) Before starting the process the test creates a new Emergency We start the process passing the Emergency inside the Parameters Map The non automatic work item will change the value of the emergency.revision field Check the process definition Check the Work Item Handler implementation
  • 24. 3rd Test: inputDataTest()Input Data Test Input/Output Specification <userTask id="_2" name="Ask for Emergency Information"> <ioSpecification> <dataInput id="_2_emergencyInput" name="emergency"/> <dataOutput id="_2_emergencyOutput" name="emergency"/> ... <inputSet> <dataInputRefs>_2_emergencyInput</dataInputRefs> ... </inputSet> <outputSet> <dataOutputRefs>_2_emergencyOutput</dataOutputRefs> </outputSet> </ioSpecification>
  • 25. 3rd Test: inputDataTest()Input Data Test Bindings/Associations <dataInputAssociation> <sourceRef>emergency</sourceRef> <targetRef>_2_emergencyInput</targetRef> </dataInputAssociation> <dataOutputAssociation> <sourceRef>_2_emergencyOutput</sourceRef> <targetRef>emergency</targetRef> </dataOutputAssociation>
  • 26. 4th Test: emergencyWithRulesTest()Emergency With Rules Test It creates a basic interaction with our business process and our business rules Uses the MyHumanChangingValuesSimulator WorkItemHandler Handler Before starting the process the test creates a new Emergency We start the process passing the Emergency inside the Parameters Map The rules will evaluate the type of emergency and it will decide and create a new Vehicle for according the situation Review the process and rules definition and the Asserts in the test
  • 27. 5th Test: reactiveProcessAndRulesTest()Reactive Process and Rules Test It creates a basic interaction with our business process and our business rules Uses the MyHumanChangingValuesSimulator WorkItemHandler Handler Before starting the process we use a different thread to fire all the rules when they get activated -> Reactive Mode When the conditions of the rules matches, the rule is automatically triggered without waiting the fireAllRules() method We need a separate thread that is continuously evaluating the activations
  • 28. 5th Test: reactiveProcessAndRulesTest() Reactive Process and Rules Test (cont.) We start the process passing the Emergency inside the Parameters Map The rules will evaluate the type of emergency and it will decide and create a new Vehicle for according the situationIn this case we dont need to call the fireAllRules() method afterthe completion of the first human activity But we need to wait because multiple threads are now involved
  • 29. Some NotesSome Notes about the test WorkItemHandlers let us attach domain specific activities All the tests use Custom WorkItemHandlers to simulate human interaction This is to not complicate the tests We will be dealing with real human interactions in future modules As you main notice WorkItemHandlers can be designed to be Asynchronous or Synchronous (automatic or wait states)
  • 30. Some NotesSome Notes about the test (cont.) Notice that the console logger gives you a lot of information to understand what is happening inside our knowledge sessions Notice the interaction between Rules and Processes This example its pretty simple, but shows how we can do inferences over our business processes and how we can change or modify the process variables or the process state Try to understand the XML format for a business process definition
  • 31. HomeworkHomework Debug the tests, try to understand how they work Inspect the Process File and the Rules File Play with the reactiveProcessAndRulesTest(), change the type of emergency and look how it works Modify the process definition to have one more activity before the Report that selects a Hospital based on the Type of Emergency using rules List the modification that you have done in order to get it working
  • 32. HomeworkHomework Hints: You need to create a new Domain Entity Called Hospital You need to add a new<businessRuleTask> activity to the process and the required connections You need to write some new rules that evaluates the Process, the Emergency and the Vehicle that was selected Add the required asserts to the new test to check that everything works correctly
  • 33. Homeworks SolutionsHomework Solutions Send me your homework solutions to my personal email Use the subject [JBPM5 Community Training] - Hands On labs 1 If you have doubts about the exercise, post a comment in the blog If I start receiving too much questions we can probably create a google group for answering questions or use the JBoss jBPM forum
  • 34. ConclusionsConclusions We play a little bit with our first tests that uses jBPM5 We simulate some human interactions in order to understand basic concepts about: The business process definition The rules definitions The execution behavior Now we now the basic structure of a simple proyect that uses jBPM5 and all the things that we need to have in our environment in order to work with it
  • 35. Next ModulesStay tuned for the next modules that will explain importanttopics such as: The Business Process Modeling and Notation V2 Real Human Interactions inside our processes Task List Oriented User interfaces using different technologies etc.
  • 36. Related LinksYou can find more information, examples, tutorials andmore in: Salaboy Blog http://salaboy.wordpress.com Plug Tree Blog http://www.plugtree.com
  • 37.    Questions?
  • 38. Enjoy! Questions and Feedback arealways appreciated!
  • 39.     Contact us atwww.plugtree.com