About the Timeout Processing sample

The Timeout Processing sample demonstrates the use of the timeout function, as provided by the Timeout Control and Timeout Notification nodes. You can use these nodes to drive message flows automatically at regular intervals - these are known as automatic timeouts. Or you can provide controlled timeouts to applications on a per-message basis.

You can accomplish automatic timeouts with a single Timeout Notification node running in Automatic mode. You must provide an interval (in seconds) as a configuration parameter to determine the period between adjacent flow invocations. Uses of automatic timeouts include:

You can accomplish controlled timeouts with one or more Timeout Control nodes in tandem with a Timeout Notification node. You must associate the nodes together by providing the same Identifier as a configuration parameter. (There is a many-to-one relationship between Timeout Control and Timeout Notification nodes - in other words, a single Timeout Notification node will process the timeout requests of all Timeout Control nodes with a matching Identifier.) The Timeout Control nodes receive incoming messages containing fixed format timeout requests, which are then validated and stored, and processed by the Timeout Notification nodes when they have expired.

A timeout request has a unique identifier within the scope of the Timeout nodes processing it. It is not the same as the Identifier used to associate Timeout nodes together. A timeout request is based on a start time, an interval, and a count. You can configure timeout requests to start at any point in the future, and to ping once or many times with a count of 1 or above. If count is greater than 1, then the adjacent pings are separated by the number of seconds provided in the interval.

The Timeout Processing sample contains two message flows: AutomaticTimeout and ControlledTimeout.

AutomaticTimeout message flow

The figure shows to use a Timeout Notification node in Automatic mode:

Automatic timeout flow

This flow is set to ping once every ten seconds while the broker is running.

ControlledTimeout message flow

The figure shows how to use Timeout Control and Timeout Notification nodes together. This single .msgflow file contains two message flows: one to request the timeouts and one to process them.

Controlled timeout flow

These flows are driven by the test messages described below which contain timeout requests and are processed by the TimeoutAll and TimeoutFragment Timeout Control nodes. These nodes validate the timeout requests and store the messages for the Controlled Timeout Notification node in the second flow to process as they arrive.

The TimeoutAll node stores the entire incoming message, and the TimeoutFragment node stores a defined part of the incoming message. This behaviour is controlled by the properties under the Message tab of the Timeout Control node.

Test messages

The four test messages used to drive the ControlledTimeout message flow are straightforward XML messages that contain invoice details for a customer. The following XML is an example of one of the four messages:

<SaleEnvelope>
<Header>
<SaleListCount>1</SaleListCount>
<TimeoutRequest>
<Action>SET</Action>
<Identifier>tentimes</Identifier>
<Count>10</Count>
<Interval>10</Interval>
<AllowOverwrite>FALSE</AllowOverwrite>
</TimeoutRequest>
</Header>
<SaleList>
<Invoice>
<Initial>K</Initial><Initial>A</Initial>
<Surname>Braithwaite</Surname>
<Item>
<Code>00</Code><Code>01</Code><Code>02</Code>
<Description>Twister</Description>
<Category>Games</Category>
<Price>00.30</Price>
<Quantity>01</Quantity>
</Item>
<Item>
<Code>02</Code><Code>03</Code><Code>01</Code>
<Description>The Times Newspaper</Description>
<Category>Books and Media</Category>
<Price>00.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>00.50</Balance>
<Currency>Sterling</Currency>
</Invoice>
<Invoice>
<Initial>T</Initial><Initial>J</Initial>
<Surname>Dunnwin</Surname>
<Item>
<Code>04</Code><Code>05</Code><Code>01</Code>
<Description>The Origin of Species</Description>
<Category>Books and Media</Category>
<Price>22.34</Price>
<Quantity>02</Quantity>
</Item>
<Item>
<Code>06</Code><Code>07</Code><Code>01</Code>
<Description>Microscope</Description>
<Category>Miscellaneous</Category>
<Price>36.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>81.84</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>

The <TimeoutRequest> field embedded in the <Header> is used by the Timeout Control node to determine the requested timeout to be processed by the Timeout Notification node. In this case, the starting date and time are not defined so they take the default values of TODAY and NOW. The information specified in the <TimeoutRequest> field requests that the timeout should ping ten times, ten seconds apart, before completing.

Two of the supplied messages contain timeout requests that set timeouts, one to ping ten times and finish, the other to continue indefinitely. The other two test messages contain cancellation requests for the two timeout requests, and are processed in the same manner.

Back to sample home