About the Timeout Processing sample

The Timeout Processing sample demonstrates the use of the timeout function, as provided by the TimeoutControl and TimeoutNotification nodes. You can use these nodes to drive message flows automatically at regular intervals, which 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 TimeoutNotification node that is 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 TimeoutControl nodes in tandem with a TimeoutNotification node. You must associate the nodes together by providing the same Identifier as a configuration parameter. (A many-to-one relationship exists between TimeoutControl and TimeoutNotification nodes, that is, a single TimeoutNotification node processes the timeout requests of all TimeoutControl nodes with a matching Identifier.) The TimeoutControl nodes receive incoming messages that contain fixed format timeout requests, which are then validated and stored, and processed by the TimeoutNotification nodes when they have expired.

A timeout request has a unique identifier within the scope of the Timeout nodes that are processing it. It is not the same as the Identifier that is 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 more. If the count is greater than 1, the adjacent pings are separated by the number of seconds that are provided in the interval.

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

AutomaticTimeout message flow

The diagram shows you how to use a TimeoutNotification 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 diagram shows how to use TimeoutControl and TimeoutNotification 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, which are described later in this topic, that contain timeout requests and are processed by the TimeoutAll and TimeoutFragment TimeoutControl nodes. These nodes validate the timeout requests and store the messages for the Controlled TimeoutNotification 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 behavior is controlled by the Message properties of the TimeoutControl node.

Test messages

The four test messages that are 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 that is embedded in the Header is used by the TimeoutControl node to determine the requested timeout to be processed by the TimeoutNotification node. In this case, the starting date and time are not defined, they therefore take the default values of TODAY and NOW. The information that is specified in the TimeoutRequest field requests that the timeout pings 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