Running the RegexFilterNode sample

After you have imported and partially set up this sample, then performed the appropriate setup instructions, you can run the sample by following the instructions in the Running the sample section below.

This topic also includes an example input test message and a corresponding output message, so that you can confirm that the sample has worked.

Input test message

The test message used in running this sample is based on the following format:

<regexfilter>
<regex>out</regex>
</regexfilter>

where regex is the value of the user-defined property filterField (default is regex), and out is the value of the user-defined property filterRegex (default is out). When the value of the filterRegex is out, the message is routed to the out terminal of the RegexFilterNode. A value of anything else will route the message to the alternate terminal.

Running the sample

This sample uses the message flow RegexFilterNodeFlow. It contains one input queue called JAVACOMPUTE.REGEX.IN, and the message flow can route the message to one of three output queues (JAVACOMPUTE.REGEX.OUT, JAVACOMPUTE.REGEX.ALTERNATE and JAVACOMPUTE.REGEX.FAILURE).

To run the sample:

  1. Switch to the Broker Application Development perspective on IBM WebSphere Message Broker Toolkit.
  2. Open the test message enqueue file, RegexFilterNodeMessage.
  3. Click Write to queue. A message is sent to the JAVACOMPUTE.REGEX.IN queue. The message flow uses the RegexFilterNode node to route the message to either the JAVACOMPUTE.REGEX.OUT queue or the JAVACOMPUTE.REGEX.ALTERNATE queue, depending on the value of the user-defined property filterRegex.
  4. To check that the message has reached the correct queue use WebSphere MQ Explorer.
    1. Start WebSphere MQ Explorer.
    2. Expand the folders under the queue manager WBRK6_DEFAULT_QUEUE_MANAGER, and select Queues.
    3. When refreshing WebSphere MQ Explorer ensure that the Queues folder is selected and not an actual queue name. If you select a queue name, not all the queues shown will be refreshed.
  5. Refresh the queue display to show the current number of messages on each queue. A message should appear on the JAVACOMPUTE.REGEX.OUT queue or the JAVACOMPUTE.REGEX.ALTERNATE queue.
  6. To view this output message, go back to IBM WebSphere Message Broker Toolkit and click Get a message from a Queue on the toolbar.
  7. Type in a Queue Manager name of WBRK6_DEFAULT_QUEUE_MANAGER, and a Queue name of JAVACOMPUTE.REGEX.OUT or JAVACOMPUTE.REGEX.ALTERNATE.
  8. Click Read From Queue to display the contents of the output message.
  9. Compare this with the expected output message.

Try repeating the steps above, after editing the input message so that the value of filterRegex is not out. You should see the message routed to the JAVACOMPUTE.REGEX.ALTERNATE queue instead.

If all the steps above have worked then the sample is complete. Take a look at the Java code in the message flow RegexFilterNodeFlow to see how the message routing was achieved.

Expected output message

The output message from the sample should be identical to the input message, as this sample covers only routing of messages, not transformation. When the input message contains a value of out for filterRegex, then the message is routed to the out terminal. Otherwise it is routed to the alternate terminal.

<regexfilter>
<regex>out</regex>
</regexfilter>

Main Page iconBack to Running the JavaCompute Node sample