You must complete the setup instructions, see Setting up the Collector Node sample, and import and deploy the message flow, see Collector Node sample, before you can run the Collector Node sample.
Note. You might find it simpler to initially save the files to a temporary directory, so that when you run the sample you can copy and paste the files into the directory that is monitored by the FileInput node that you have already set up. This action ensures that the files are delivered to the integration node within the batch timeout of the Collector node.
If you encounter any problems when you run the sample, see Resolving problems when running samples in the IBM Integration Bus documentation, and check the "Problem determination" section later in this topic.
When you have completed setting up the sample, the FileInput node, fileinput, monitors the directory for delivery details for customer orders 111 and 222.
Note: Depending on how quickly you submit the customer orders, the input for the two orders might cause the flow to produce either a single batched invoice output message containing both orders, or each order might go into their own batch and therefore two invoice output messages are produced.
To run the sample for customer orders 111 and 222, messages with the following information must be put to the appropriate WebSphere MQ queues:
You must put the customer number order file into the directory that you created when you set up the sample.
To run the sample for customer orders 111 and 222:
Note: If the message flow is running, the 111.order and 222.order files are read and then almost immediately removed and, therefore, the files are no longer visible.
<Costing> <CustomerNumber>111</CustomerNumber> <Product>Toaster</Product> <UnitPrice>4.99</UnitPrice> </Costing>This action also starts the Test Client WebSphere MQ message listener that is configured to continue to listen for messages on all output and expiry queues for 5 minutes. When all the messages are processed, to end the listener click Stop (the blue square button on the message test flow events toolbar), at any time.
<Packaging> <CustomerNumber>111</CustomerNumber> <Postage>1.95</Postage> </Packaging>
<Costing> <CustomerNumber>222</CustomerNumber> <Product>Food Processor</Product> <UnitPrice>35.99</UnitPrice> </Costing>
<Packaging> <CustomerNumber>222</CustomerNumber> <Postage>5.55</Postage> </Packaging>
<Invoices> <Invoice> <InvoiceNumber>111</InvoiceNumber> <Product>Toaster</Product> <TotalCost>6.94</TotalCost> <Delivery>2 days</Delivery> </Invoice> <Invoice> <InvoiceNumber>222</InvoiceNumber> <Product>Food Processor</Product> <TotalCost>77.53</TotalCost> <Delivery>4 days</Delivery> </Invoice> <Date>2009-10-16</Date> <Time>19:24:34</Time> </Invoices>However, because the Collector node is triggered every 90 seconds, you might not have enqueued the messages within a single interval, therefore you might receive two separate invoice messages, one with invoice 111 and the other with invoice 222.
Save the contents of 333.order into the directory that you created in the Setup instructions. For example:
Note: If the message flow is running, the 333.order file is read and then almost immediately removed and, therefore, the file is no longer visible.
<Costing> <CustomerNumber>333</CustomerNumber> <Product>Kettle</Product> <UnitPrice>5.99</UnitPrice> </Costing>This action also starts the Test Client WebSphere MQ message listener, which continues to listen for messages on all output and expiry queues for 5 minutes. When all the messages are processed, to end the listener click Stop (the blue square button on the message test flow events toolbar) at any time.
<Packaging> <CustomerNumber>333</CustomerNumber> <Postage>2.05</Postage> </Packaging>
<Invoices> <Invoice> <InvoiceNumber>333</InvoiceNumber> <Product>Kettle</Product> <TotalCost>8.04</TotalCost> <Delivery>2 days</Delivery> </Invoice> <Date>2009-10-16</Date> <Time>19:28:03</Time> </Invoices>
The output message on CollectorNodeSample_111_222_orders.mbtest contains the invoices for customer orders 111 and 222. The output messages have the following format:
<Invoices> <Invoice> <InvoiceNumber>111</InvoiceNumber> <Product>Toaster</Product> <NumberOrdered>1</NumberOrdered> <TotalCost>8.94</TotalCost> <Delivery>2 days</Deliver> </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>
The output message shows how the first Collector node, CollectByCustNum, has collated the customer orders for 111 and 222 to create two message collections. Each collection has been propagated to the first Compute node, where the data from the collection for each order is combined to create an invoice. Two messages are propagated by the Compute node, one for each customer order. When these messages arrive at the second Collector node, CollectUntilTrigger, a message collection is completed every 15 seconds, so that both of these messages are added to the same collection.
The output message on CollectorNodeSample_333_orders.mbtest contains the invoice for customer order 333.
<Invoices> <Invoice> <InvoiceNumber>333</InvoiceNumber> <Product>Kettle</Product> <NumberOrdered>1</NumberOrdered> <TotalCost>9.94</TotalCost> <Delivery>2 days</Deliver> </Invoice> <Date>2007-08-10</Date> <Time>17:18:22</Time> </Invoices>
The first Collector node, CollectByCustNum, collates the customer order for 333 to create one collection. This collection is then propagated to the first Compute node, where the data from the collection for the order is combined to create an invoice. This message is then propagated to the second Collector node, CollectUntilTrigger. This node completes a collection every 15 seconds, so that this order arrives after the collection containing orders 111 and 222 is completed, and is added to a new collection.
The completed collection containing orders 111 and 222, and the completed collection containing order 333, are both held at Collector node CollectUntilTrigger until the time interval from the TimeoutNotification node has expired. After 300 seconds, when the timeout has expired, all of the completed collections are propagated to the final Compute node. In this Compute node the following two messages are generated:
Both messages contain the same timestamp information because they are propagated to the last Compute node at the same time, that is, when the timeout interval has expired.
Note: You might receive the output invoice message for customer order 333 on CollectorNodeSample_111_222_orders.mbtest and vice versa, because both messages are propagated from the Collector node at the same time, and can arrive on the output queue COLL_OUT in any order.
Three Trace nodes are included in the CollectorNodeSample message flow. Two nodes are placed after a Collector node to show the message tree that is created by the Collector node for each message collection. Trace node Trace1 is placed after Collector node CollectByCustNum and Trace node Trace2 is placed after Collector node CollectUntilTrigger. The third Trace node is placed after TimeoutNotification node TimerTrigger and logs the TimeoutNotification node triggers.
All Trace nodes write to the same file, collectorNodeSample.trc, and include writing text that defines where the output is from and a time stamp. This scenario enables you to watch this trace file to observe the sequential events as the timer ticks and the collections are formed and propagated.
You can find the collectorNodeSample.trc trace file in the following locations:
The following links to trace outputs show examples of the output from two of the Trace nodes. The start of each message collection is hightlighted in blue, and the start of the subtree for each Input terminal and the message data from each Input terminal is hightlighted in red.
If messages are sent to the COLL_EXPIRE1 queue, the message collection was not complete before the timeout on the Collector node CollectByCustNum expired. A reason might be that one of the inputs from the two MQInput nodes or the FileInput node were not received before the collection expired. The expiry time on the CollectByCustNum node is set to 300 seconds. If you received a message on the on the COLL_EXPIRE1 queue, try to run the sample again and input the file and WebSphere MQ messages within the 300 second timeout.
If your Invoke event times out without receiving any messages, and you do not have any messages on COLL_EXPIRE1, a message might have been put on COLL_OUT after the Test Client stopped waiting. Check the queue depth with WebSphere MQ Explorer. You must extend the wait time of the Test Client from its default, 120 seconds, to 300 seconds as stated in the setup instructions. Depending on how quickly you perform Steps 1-6, it might take more than 2 minutes for a message to be produced.