Today I am going to discuss step by step, how you can implement a BPMN process that starts with a message start event when it receives a message from a JMS queue.
Overview
There are 5 types of start events in Activiti. They are:
- Non Start Event
When we use a non start event to start a process, it means we do not specify the trigger for starting the process instance. The graphical notation is a blank circle. - Message Start Event
When we want to start a process instance by sending a named message, we can use the message start event. The graphical notation is a circle with an envelop symbol in the middle. - Timer Start Event
If a process instance is needed to be started at a given time, then we can use a timer start event. The graphical notation is a circle with a clock symbol in the middle. - Error Start Event
Using an error start event we can trigger an event sub-process only. We cannot trigger a process instance using this. The graphical notation is a circle with an error event symbol in the middle. - Signal Start Event
Just as in a message start event, a signal start event is used to start a process by sending a named signal. The graphical notation is a circle with a triangle symbol in the middle.
For further details please visit the Activiti User Guide
I am going to implement a BPMN process to get a string input from the user and print it. As the start event I will use a message start event.
Step 1: Create a new Activiti Project in eclipse and add a new Activiti Diagram file for the src/main/resources/diagrams package.
Step 2: Draw the following process in it.
Figure 1 – Sample BPMN Porcess
Step 3: Select ‘Get Name’ task and add a variable called name with following properties;
- id – name
- Name – name
- Type – string
- Required – true
- Readable – true
- Writable – true
Figure 2 – Name variable in the Get Name task
Step 4: Select the ‘Print Name’ task and add another variable called name with following properties;
- id – name
- Name – name
- Type – string
- Required – true
- Readable – true
- Writable – false
Figure 3 – Name variable in the Print Name task
Step 5: Click on the BPMN Activiti Editor area and at the bottom on the Properties tab you can find a sub-tab called Message. Fill this as follows:
Figure 4 – Specifiying the message
You can directly enter the details of the message within the process source code as following:
Insert the following line within the <definitions> tag.
<message id=“startEvent” name=“startEventMessage”></message>
Step 6: Select the message start event and provide the message ref as “startEvenetMessage”.
Figure 5 – Providing the message ref from the Properties panel
You can directly include it in the source code as well. Insert the following line within the startEvent tags. Reference is given for the ID of the message specified.
<messageEventDefinition messageRef=“startEvent”></messageEventDefinition>
That is it. Now you have implemented a simple BPMN process with a message start event.
How to run this process?
You have to use a server to run this BPMN process. I am using the WSO2 Business Process Server (BPS) which you can download here.
Deploy this process and run it. You can see that the process is triggered using the message sent.
Following links will be useful in setting up the server and deploying the process.
Setting up the server:
https://docs.wso2.com/display/BPS350/Getting+Started
Deploying the sample and running it:
https://docs.wso2.com/display/BPS350/BPMN+Samples
So, that’s it! Hope you found it useful. Stay with me for more exciting blog posts!
nice work! 🙂
LikeLike