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 |
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:
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.
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:
|
Run Simulation
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