Prev Next

Message Event

When used in normal sequence flow, the Message Event can be used to either send or receive a message.

  • When sending a message to a participant, the values of all property parameters are copied; once the message is sent the token continues along the sequence flow
  • When receiving a message, the event is triggered when a message is received.

This example demonstrates the Message Event features. We will first create the BPMN model, then configure BPSim and run the simulation.

Create BPMN Model

Sequence

Pool1

  • The token starts from StartEvent1
  • On receiving the token, Sender (a Throwing Intermediate Message Event) creates a message and copies the current property values to the message
  • Sender sends the message to the 'To' participant (Pool2, StartEvent2)
  • Sender forwards the token along its sequence flow, as far as Receiver
  • The token waits at Receiver until a message arrives

Pool2

  • StartEvent2 receives a message and starts a token
  • StartEvent2 copies the values from the message and sets these in the token
  • StartEvent2 forwards the token along its sequence flow until EndEvent3
  • EndEvent3 creates a message and copies the current property values to the message
  • EndEvent3 sends the message to the 'To' participant (Pool1, Receiver)

Pool1 continued

  • The waiting Receiver is awakened and the property values are updated from the arriving message

Create Diagram

  • Create a BPMN 2.0 Collaboration diagram
  • Select the option 'Create this diagram within a new CollaborationModel'
  • Create Pool1 and Pool2 by dragging the 'Pool' icon from the Toolbox onto the diagram

Within Pool1

  • Create a Start Event of type 'None', named StartEvent1
  • Add a Sequence Flow to the target Intermediate Event of type 'Throwing Message', called Sender
  • Add a Sequence Flow to the target Activity of type 'abstract', called Activity1
  • Add Sequence Flows to the target:
         -  End Event of type 'None', called EndEvent1
         -  End Event of type 'None', called EndEvent2

Within Pool2

  • Create a Start Event of type 'Message', called StartEvent2
  • Add a Sequence Flow to the target Activity of type 'abstract', called Activity2
  • Add a Sequence Flow to the target Gateway of type 'Exclusive', called Gateway2
  • Add Sequence Flows to the target:
         -  Activity of type 'abstract', called Activity3
         -  Activity of type 'abstract', called Activity4
  • Add Sequence Flows from Activity3 and Activity4 to the target Gateway of type 'Exclusive', called Gateway3
  • Add a Sequence Flow to the End Event of type 'Message', called EndEvent3

Message Flows

  • Add a Message Flow from Sender to StartEvent2
  • Add a Message Flow from EndEvent3 to Receiver

Configure BPSim

In order to show the Message Flow's ability to carry values, we create a Property Parameter 'M1' and change its value in each Activity. We then use the value of 'M1' as part of the expression for the condition of the Sequence Flow.

Task

Description

Create Artifact and Package

  • Open the Configure BPSim window ('Simulate > BPMN/BPSim > Manage > Open BPSim Manager')
  • Click on the button in the 'Select/Create Artifact' field and create an Artifact called 'MessageEvent-StartEvent-IntermediateEvent-EndEvent'
  • In the 'Select Package' field select the Package containing the model

All the BPMN elements from the model are loaded into the Configure BPSim window.

Property Values

We will give the Property Parameter 'M1' an initial value of 10 at StartEvent1. Then we change the value as the token flows through the processes and the value is copied across participants.

In the element list on the left of the dialog:

  • Expand the 'StartEvent' group, click on StartEvent1 and on the 'Properties' tab, and overtype New Property with 'M1'; in the 'Value' field click on the button and select 'Constant' and 'Numeric, and type '10' in the 'Constant Numeric' field
  • Expand the 'Activity' group, click on Activity1 and on the 'Properties' tab, and overtype New Property with 'M1'; in the 'Value' field click on the button and select 'Expression', and type '{M1} + 100' in the 'Expression' field
  • Click on Activity2 and on the 'Properties' tab, and overtype New Property with 'M1'; in the 'Value' field click on the button and select 'Expression', and type '{M1} + 10' in the 'Expression' field
  • Click on Activity3 and on the 'Properties' tab, and overtype New Property with 'M1'; in the 'Value' field click on the button and select 'Expression', and type '{M1} + 10' in the 'Expression' field
  • Click on Activity4 and on the 'Properties' tab, and overtype New Property with 'M1'; in the 'Value' field click on the button and select 'Expression', and type '{M1} + 1' in the 'Expression' field

Tip: The format of {PropertyName} is a convenient short form of getProperty("PropertyName").

Control Parameters

We only need one token in this simulation for evaluating the behavior of the model.

  • In the expanded 'StartEvent' group, click on StartEvent1 and the 'Control' tab; click on the 'New parameter' drop-down arrow and select 'Trigger Count', and type in a 'Value' of '1'

Now set up the conditions for the Gateways' outgoing Sequence Flows. In the element list on the left of the dialog, expand the 'Gateway' group:

  • Expand Gateway1, click on EndEvent1 and on the 'Control' tab, then click on the 'New Parameter' drop-down arrow and select 'Condition'; in the 'Value' field click on the button and select 'Expression', and type '{M1} >= 50' in the 'Expression' field
  • Click on EndEvent2 and on the 'Control' tab, then click on the 'New Parameter' drop-down arrow and select 'Condition'; in the 'Value' field click on the button and select 'Expression', and type '{M1} < 50' in the 'Expression' field
  • Expand Gateway2, click on Activity3 and on the 'Control' tab, then click on the 'New Parameter' drop-down arrow and select 'Condition'; in the 'Value' field click on the button and select 'Expression', and type '{M1} >= 15' in the 'Expression' field
  • Click on Activity4 and on the 'Control' tab, then click on the 'New Parameter' drop-down arrow and select 'Condition'; in the 'Value' field click on the button and select 'Expression', and type '{M1} < 15' in the 'Expression' field

Run Simulation

  • On the 'Configure BPSim' dialog toolbar, click on the Run button; the 'BPSim Simulation Controller' dialog displays
  • Click on the 'Run' icon drop-down arrow and select 'Standard Simulation'; the simulation starts
  • When the simulation is finished, click on the button; the 'Property Parameter Values' dialog displays, tracing the values for properties during simulation
  • In the 'Token Number' field type '0', then click on the Query button and on the 'Group by Property' tab

Analysis

As the 'ProcessingTime' of Activity1 was set as a distribution value, it turns out that:

  • [Process1]'s 'M1' value after Pool1.StartEvent1 is '10', as expected
  • *[Process2] Pool2.StartEvent2's 'M1' value is '10'; this value is carried from a message sent by Pool1.Sender

Now there are actually two 'M1's - Process1.M1 and Process2.M1

  • [Process2] Pool2.Activity2 increased Process2.M1 by 10; [Process2.M1 == 20]
  • [Process1] Pool1.Activity1 increased Process1.M1 by 100; [Process1.M1 == 110]
  • [Process2] The condition expressions are evaluated; as '20 > 15', the token will flow to Activity3 [Process2.M1 == 20]
  • [Process2] Pool2.Activity3 increased Process2.M1 by 10; [Process2.M1 == 30]
  • [Process1] Pool1.Receiver is reached and waiting [Process1.M1 == 110]
  • [Process2] Pool2.Gateway3 serves as a Merge node and continues to EndEvent3 [Process2.M1 == 30]
  • *[Process1] Pool1.Receiver is woken up by a message(carrying M1 == 30) and Process1.M1's value changes from 110 to 30
  • [Process1] The condition expressions are evaluated; as '30 < 50', the token will flow to EndEvent2 [Process1.M1 == 30]

Notes

  • The lines marked with an asterisk (*) are the effects of Message Flows
  • The order within a process is defined; however, the order between two processes is not always predictable
  • The Throwing Message Event forks another process; the Catching Message serves as thread synchronization