Running the GoogleAPINode 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:

<googleapinode>
<key>................................</key>
<querystring>What is the time in Australia?</querystring>
</googleapinode>

where the field <key> contains the alphanumeric key obtained via e-mail by registering for the Google API (see Setup instructions), and the field <querystring> contains the string to search for.

Running the sample

This sample uses the message flow GoogleAPINodeFlow. It contains one input queue called JAVACOMPUTE.GOOGLE.IN, and the message flow can transform and route the message to one of two output queues (JAVACOMPUTE.GOOGLE.OUT and  JAVACOMPUTE.GOOGLE.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, GoogleAPINodeMessage.
  3. Click Write to queue. A message is sent to the JAVACOMPUTE.GOOGLE.IN queue. The message flow transforms the message using the GoogleAPINode node, and routes it to the JAVACOMPUTE.GOOGLE.OUT queue.
  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 click 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.GOOGLE.OUT 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.GOOGLE.OUT.
  8. Click Read From Queue to display the contents of the output message.
  9. Compare this with the expected output message.

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

Expected output message

The output message from the sample should have the following format:

<googlesearchresult>
<resultelement>
<url>...</url>
<title>...</title>
<snippet>...</snippet>
<summary>...</summary>
</resultelement>
<resultelement>
<url>...</url>
<title>...</title>
<snippet>...</snippet>
<summary>...</summary>
</resultelement>
...
</googlesearchresult>

Main Page iconBack to Running the JavaCompute Node sample