Running the Message Routing sample using a file
All the test
messages that are used in this section are
stored in the Test messages directory in the
Message routing sample message flows
Message Broker project.
If you meet problems when you run the sample,
see Resolving problems when running samples
in the WebSphere Message Broker documentation.
Running the sample
Using a whole file to route the message
The message flow can route the message to one of 20 output queues based on the
content of the message (ROUTING.OUT followed by a number from
1-19 plus a queue called
ROUTING.DEFAULT). To run this part of the sample:
- In the Broker Development view, expand the
Message routing sample message flows
project.
Under Test messages, double-click File_Whole_file_message1.mbtest
to open the file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send a message to
the ROUTING.WHOLE.FILE.IN1 queue.
The message flow routes the message to the
ROUTING.OUT1 queue.
- In the Test Client, click Dequeue,
click Get Message to read a
message from the ROUTING.OUT1 queue.
- Under Test messages, double-click File_Whole_file_message2.mbtest
to open the file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send the message to
ROUTING.WHOLE.FILE.IN1.
The message flow routes the message to the queues ROUTING.OUT18 and
ROUTING.OUT19.
- In the Test Client, click Dequeue,
click Get Message to read the routed message from the
ROUTING.OUT18 queue.
- Click the second Dequeue,
click Get Message to read the routed message from the
ROUTING.OUT19 queue.
If all of the preceding steps are successful, the first part of the sample is
complete. To find out how the routing is programmed, look at the ESQL in the message flow:
Routing_using_whole_file_Compute.
Using a record from a file to route the message
The message flow can route the message to one of 20 output queues based on the
content of the message (ROUTING.OUT followed
by a number from 1-19 plus a queue called
ROUTING.DEFAULT). To run this part of the sample:
- In the Broker Development view, expand the Message routing sample message flows
project.
Under Test messages, double-click File_Records_file_message1.mbtest to open the file in
the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send a message to
the ROUTING.RECORDS.FILE.IN1 queue.
The message flow routes the message to the
ROUTING.OUT1 queue.
- In the Test Client, click Dequeue,
click Get Message to read a
message from the ROUTING.OUT1 queue.
- Under Test messages, double-click File_Records_file_message2.mbtest to open the
file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send the message to
ROUTING.RECORDS.FILE.IN1.
The message flow routes the message to the queues ROUTING.OUT18 and
ROUTING.OUT19.
- In the Test Client, click Dequeue,
click Get Message to read the routed message from the
ROUTING.OUT18 queue.
- Click the second Dequeue,
click Get Message to read the routed message from the
ROUTING.OUT19 queue.
If all of the preceding steps are successful, the second part of the sample is
complete.
Using an in-memory cache of the file to route the message
This part of the sample uses the Routing_using_file_and_memory_cache message flow.
The message flow contains two input queues:
- ROUTING.FILE.MEMORY.IN1.
- ROUTING.FILE.REFRESH.IN1.
To run this part of the sample:
- In the Broker Development view, expand the
Message routing sample message flows project.
Under Test messages, double-click File_Memory_cache_message1.mbtest
to open the file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send a message to
the ROUTING.FILE.MEMORY.IN1 queue.
The message flow routes the message to the
ROUTING.OUT1 queue.
- In the Test Client, click Dequeue,
click Get Message to read a
message from the ROUTING.OUT1 queue.
- Under Test messages, double-click File_Memory_cache_message2.mbtest
to open the file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send the message to
ROUTING.FILE.MEMORY.IN1. The message flow
routes the message to the queues ROUTING.OUT18
and ROUTING.OUT19.
- In the Test Client, click Dequeue,
click Get Message to read the routed
message from the ROUTING.OUT18 queue.
- Click the second Dequeue,
click Get Message to read the routed
message from the ROUTING.OUT19 queue.
- Up to this point the flow is behaving exactly the same as the last
flow, but this flow is using information that is cached from the file.
To test the effect of using the cache, the file is modified to show how
the in-memory cache can be refreshed. To modify the file:
- Go the the MQSI_FILENODES_ROOT_DIRECTORY c:\MQSIFileRead.
- Open the file fileRead.csv.
- On the row KA,Braithwaite,MB8QMGR,ROUTING.OUT18,MB8QMGR,ROUTING.OUT19
change the row to the following:
KA,Braithwaite,MB8QMGR,ROUTING.OUT17,MB8QMGR,ROUTING.OUT19.
- Save the file.
- Under Test messages, double-click File_Memory_cache_message2.mbtest to open
the file in the Test Client.
- In the Test Client, click Enqueue,
click Send Message to send a message to
the ROUTING.FILE.MEMORY.IN1 queue.
The message flow routes the message to the queues
ROUTING.OUT18 and ROUTING.OUT19.
- In the Test Client, click Dequeue,
click Get Message to read a
message from the ROUTING.OUT18 queue.
Repeat this for the second dequeue.
The message is not routed to the new queue name because the file has not been reread.
- To make the flow reread the file, under Test messages open
File_Refresh_cache_message1.mbtest,
click Enqueue, click Send Message
to write the message to the ROUTING.FILE.REFRESH.IN1 queue.
- Double-click File_Memory_cache_message2.mbtest to open it in the Test Client,
click Enqueue, click Send Message
to write the message to the ROUTING.FILE.MEMORY.IN1 queue.
- In the Test Client, click the first Dequeue,
and change the queue name to be ROUTING.OUT17,
click Get Message to read the routed message from the
ROUTING.OUT17 queue.
Steps 9-14 can be repeated by changing the queue_name in the
file to one of the other queue names that are available. Instead of using the
File_Refresh_cache_message1 message, you can stop and restart the
message flow, which also causes the
cached database table to be refreshed.
If all the preceding steps are successful, the second part of the sample is
complete. To find out how the routing is programmed, look at the ESQL in the message flow:
Routing_using_file_and_memory_cache_Compute.
Understanding the results
The Message Routing sample routes the input test message to various output queues without modifying the output.
The output message is identical to the input test message, see Input test messages.
The steps given in the four parts detail to where the messages are routed.
You can check that the messages are routed to the correct queue by using
WebSphere MQ Explorer as well as by using Dequeue
in the Test Client.
Back to sample home