Table of Contents:
Introduction
In this tutorial we will create a process that reacts to events - new connections and timeouts.
In this scenario, there are 4 nodes:
- One moving node called “M” (M0 in screenshot below, with the red line showing the movement path)
- Three static nodes, called “S”. (S1-S3 in screenshot below).
In this tutorial, M will run a process that is notified if a new connection is created. This happens whenever M passes by each of the static nodes. When a connection is established, M should send a message to the node it just connected to and wait for a response message. If a response is received, the process ends. However, if 100 seconds passes and no response has been received, M should start waiting for another new connection to happen, and then again send a message and wait for a response.
Such behaviour modelled as a process would look like this.
As you can see, it involves a kind of a loop. Let’s see how to construct this process model.
Connection signals
In addition to messages, processes can handle signals and other events. For instance, STEP-ONE sends signals to process engines when connections are created or broken.
To handle new connections, add an “Intermediate Signal Catching Event” to your process. Similar to messages and message catching events, you have to define the signals for your process and make the signal catching event refer to them.
To define signals for your process, make sure no process elements are activated (e.g. click on background of modeller) and select “Signal definitions”. The signals definition window has some templates for defining STEP-ONE signals, including New Connection signals. Select the respective template and save the new signal definition. Now you can associate the Signal Catch Event with the Signal Definition.
The following video demonstrates these steps:
Whenever a connection-related signal is raised, the STEP-ONE engine adds a special variable to the process instance: “lastConnectAddress”. The value of the variable is the network address of the external node with whom this connection-related signal happened with.
Add a Send BP Message Task right after the Signal catching event and use the above variable as the destination (this would look like: ${lastConnectAddress} ). Also specify some values for message size and name (e.g. “Some message”).
Waiting for message response with a timeout
To receive the response message, we know that we can use Intermediate message catching events, as we have done in Tutorials 1-2. What if we only want to wait for the response for some limited amount of time?
For this we will use a Timer-based event and an Event gateway
An Event gateway is a split in the control flow of the process, the process will be in a wait state until any of the events in the outgoing flows of the gateway are triggered. In this tutorial, we will use the event gateway with 1 message catching event and 1 timer catching event as the outgoing flows.
Add the event-based gateway from the palette to the model.
Timer-based event
Add an intermediate timer catching event as one of the outgoing flows for the gateway.
STEP-ONE supports duration-based and cycle based timer events. Specify the Time Duration property value to be “PT100S” - this indicates 100 seconds. The format used here is ISO8601 .
Also add an Intermediate message catching event for a message with the name “Response Message”. If you have connected the flow arrows correctly, you should have something like this:
Flow management
To finish the process, let’s specify that the process should end if the response is indeed received. In the other case, if the timer event is triggered, the process execution should go back to the “New Connection” catching event and try to repeat the message exchange again. Add the necessary flows to your diagram to set this up. The end result was shown in the process diagram at the start of this tutorial.
Running the tutorial
If you run this simulation, you should see that M0 will send the message to S1 right after their connection is established. However, we have not configured a process for any of the S nodes, so M0 will not receive any response message. Meanwhile, as M0 is still waiting for the response, M0 also passes S2, but no message is sent to S2, since M0-s execution is waiting at the event gateway.
Then, after the 100s time event happens, M0 is waiting for new connection signals again, and will send a message to S3 once a connection with S3 is established.
In the above screenshot, notice that while we see connections being established with S2, no message exchange is happening.