About the Collector Node sample

The Collector Node sample contains a message flow with two Collector nodes.

The sample is based on the following scenario:

  1. The flow creates an invoice record from three separate parts of a specific order (customer order details, warehouse information, and shipping costs).
  2. The flow groups all the invoices into batches, which are sent at 90 second intervals.

The invoice for an order is generated by taking input from three sources:

The following diagram shows the CollectorNodeSampleFlow message flow:

Screen capture of the CollectorNodeSampleFlow message flow

The first Collector node in the message flow demonstrates:

The second Collector node in the message flow demonstrates:

The warning symbol that is displayed on the Collector nodes in the diagram indicates that the Catch terminals are not connected.

The CollectorNodeSampleFlow message flow

Message flow input

The message flow takes input from the following three sources:

The input from the three input nodes is sent to the first Collector node in the flow, CollectByCustNum, which is configured to complete a collection when one message from each input source matches the criteria configured in the Collector node.

Pattern matching can be used to correlate messages into a message collection based on the content of incoming data. Pattern matching can be defined on a given input terminal. The pattern matching that is configured on each input terminal can use two fields to set up the pattern matching:

In the Collector node, pattern matching is set in the Collection definition table. You can find this table on the Basic page of the Properties view.

The CollectByCustNum Collector node has three input terminals to collect input from the three input nodes:

The following diagram shows the three input terminals:

Screen capture of the CollectByCustNum Collector node

On CollectByCustNum the input from MQInput node MQ COLL_IN1 and FileInput node fileinput are correlated on CustomerNumber. No pattern matching is required on input terminal IN3, instead the input from MQInput node MQ COLL_IN3 contains a postage price that is added to each collection.

In the following example, the CustomerNumber is 111. The input to the three input terminals is:

Message collections are created with subtrees containing the original order, delivery information from the warehouse, and a postage price.

The completed message collection is propagated to the Compute node, Compute1, which combines the input to create a new invoice message. This Compute node performs the following tasks:

The new message that is created by the Compute node, has the following structure:

<Invoice> 
    <CustomerNumber>111</CustomerNumber> 
    <Product>Toaster</Product> 
    <Quantity>1</Quantity>  
    <Price>8.94</Price> 
    <Delivery>2 days</Delivery> 
</Invoice> 

The invoice message that is created in Compute1 is propagated to the second Collector node in the message flow, CollectUntilTrigger. This Collector node has one input terminal that is called IN4. In this Collector node the Timeout property is used to complete message collections, rather than the Quantity property that is used by the first Collector node. The Timeout property is set to 30 seconds so that all messages received within the 30 second timeout period form a completed collection.

Event coordination is also enabled in this node. A Timeout Notification node is connected to the Control terminal of the Collector node. Therefore, completed collections are not propagated to the next node in the flow until the control terminal is triggered by the TimeoutNotification node. The TimeoutNotification node is set to send a message every 90 seconds.

The message collections are sent to a Compute node, Compute2. The Compute node takes the message data from each collection and adds time and date information to form the final output message. Each collection might contain more than one invoice depending on the number of invoice messages that are added to each collection in Collector node CollectUntilTrigger.

The final output message is in the form:

<Invoices> 
  <Invoice> 
     <InvoiceNumber>111</InvoiceNumber> 
      <Product>Toaster</Product> 
     
<NumberOrdered>1</NumberOrdered> 
      <TotalCost>9.94</TotalCost> 
      <Delivery>2 days</Delivery>       
 </Invoice> 
  <Invoice> 
     <InvoiceNumber>222</InvoiceNumber> 
      <Product>Food
Processor</Product> 
     
<NumberOrdered>2</NumberOrdered> 
      <TotalCost>75.93</TotalCost> 
      <Delivery>4
days</Deliver>       
 </Invoice>  
 <Date>2007-08-10</Date> 
 <Time>17:18:22</Time> 
</Invoices>

Notice in the message flow that a Compute node follows each Collector node. You must have either a Compute node or a JavaCompute node following a Collector node, because only these nodes can parse the message tree that is propagated by a Collector node. You can use a Compute node or JavaCompute node to take message parts from the message collection and to generate new messages that can be processed by other nodes in your message flow.

Back to sample home