A Simple Application to Learn Activiti Message Satrt Event

Logo-Activiti-freigestellt-WEB1

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

process

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

namevar

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

printName
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:

message

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”.

msgstart

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!

Advertisements

2 thoughts on “A Simple Application to Learn Activiti Message Satrt Event

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s