Running the Simplified Database Routing sample

You can run the Simplified Database Routing sample to demonstrate the following tasks:

For each task, you put a message on the same WebSphere MQ queue SIMPLERROUTEDB_IN. The SimplifiedDBRouting message flow gets the message from the queue and processes the message. The following instructions describe how to put the supplied self-defining XML messages through the Simplified Database Routing sample message flow and what output you can expect to receive from the message flow in each case. Because the messages do not update the SROUTEDB database, you can send any of the four messages into the message flow in any order.

You can view the contents of the sample database. For DB2 databases use the tools provided by DB2; for example, the DB2 Control Center.

When you run the sample, you might see error or warning messages similar to The XMLNSC schema element was not found and Mandatory expression is not a valid syntax in the Problems view of the WebSphere Message Broker Toolkit. These warnings or errors indicate that the XPath expressions in the properties of some of the nodes in the message flow do not meet XPath validation requirements that are set as preferences in the WebSphere Message Broker Toolkit. These messages do not affect the behavior of the sample at runtime. However, if the XPath validation preferences are set so that error messages are displayed in the Problems view, you cannot add the message flow to a broker archive file, or rebuild a broker archive file that already contains the message flow. You might also be unable to view the message flow in the Message Flow editor. To set the XPath validation preferences to be less strict, and to display warnings instead of errors:

  1. Click Window > Preferences, expand Broker Development.
  2. Expand XPath, click Validation.
  3. Select Warning from the menu for each of the validation options.
  4. Click OK.
  5. Save the message flow after you have changed the preferences so that warnings are displayed instead of errors. When you save the message flow, it is revalidated.

If messages are displayed on the SIMPLERROUTEDB_FAILURE queue when you run the sample, check that the default DBMS JDBC provider settings that are set for the JDBCProvider alias SIMPLERROUTEDB in the broker registry are correct for your environment. For more information, see either Creating a JDBC provider entry for a DB2 database or Creating a JDBC provider entry for an Oracle database. If you have any other problems when you run the sample, see Resolving problems when running samples in the WebSphere Message Broker documentation.

Running the SimplifiedDBRouting message flow, with the test message that is in usedbretrievenode.mbtest

The SimplifiedDBRouting message flow retrieves employee details on the employee that is listed in the EmpNumber (Employee Number) field of the input message. The message flow modifies the message, finally comparing the content of the message with the details of the manager of the employee in a second database lookup.

To run the SimplifiedDBRouting message flow:

  1. In the Broker Development view, expand the Simplified Database Routing Message Flows project, double-click the usedbretrievenode.mbtest file to open it in the Test Client.
  2. In the Test Client, click Enqueue.
  3. Click Send Message. This input message is put on the SIMPLERROUTEDB_IN queue.
  4. In the Test Client, click the first Dequeue.
  5. Click Get Message to read a message from the SIMPLERROUTEDB_SNRSTAFF queue. This reply message confirms that Mr David Brown (employee: 000010) must be logged and recognised as a senior member of staff within the company. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000010</EmpNumber>
          	<FirstName>DAVID</FirstName>
          	<LastName>BROWN</LastName>
          	<YrsInService>10</YrsInService>
          	<AgeInYears>54</AgeInYears>
          	<WorkDept>D01</WorkDept>
    </EmpRecord>
  6. In the Test Client, click the second Dequeue.
  7. Click Get Message to read a message from the SIMPLERROUTEDB_ORDERCLOCK queue. This reply message confirms that Mr David Brown (employee: 000010) must be given a clock by his manager, awarded for ten years service in the company. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000010</EmpNumber>
          	<FirstName>DAVID</FirstName>
          	<LastName>BROWN</LastName>
          	<YrsInService>10</YrsInService>
          	<AgeInYears>54</AgeInYears>
          	<WorkDept>D01</WorkDept>
    </EmpRecord>

Running the SimplifiedDBRouting message flow, with the test message that is in usedbretrievenode_nofiltermatch.mbtest

The SimplifiedDBRouting message flow retrieves employee details on the employee listed in the EmpNumber (Employee Number) field of the input message. The message flow modifies the message, finally comparing the content of the message with the details of the manager of the employee in a second database lookup.

To run the SimplifiedDBRouting message flow:

  1. In the Broker Development view, expand the Simplified Database Routing Message Flows project, double-click the usedbretrievenode_nofiltermatch.mbtest file to open it in the Test Client.
  2. In the Test Client, click Enqueue.
  3. Click Send Message. This input message is put on the SIMPLERROUTEDB_IN queue.
  4. In the Test Client, click Dequeue.
  5. Click Get Message to read a message from the SIMPLERROUTEDB_DEFAULT queue. This reply message confirms that Mrs Sally Kwan (employee: 000020) satisfies neither DatabaseRoute node filtering expression because she has less than ten years service and is also the manager of her work department and so cannot be older than herself. As a result, the modified input message is routed to the default queue. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000020</EmpNumber>
          	<FirstName>SALLY</FirstName>
          	<LastName>KWAN</LastName>
          	<YrsInService>9</YrsInService>
          	<AgeInYears>27</AgeInYears>
          	<WorkDept>D00</WorkDept>
    </EmpRecord>

Running the SimplifiedDBRouting message flow with the test message that is in bypassdbretrievenode.mbtest

The SimplifiedDBRouting message flow compares employee details, that are given in the input message, with the details of their manager, that are acquired from a database lookup.

To run the SimplifiedDBRouting message flow:

  1. In the Broker Development view, expand the Simplified Database Routing Message Flows project, double-click the bypassdbretrievenode.mbtest file to open it in the Test Client.
  2. In the Test Client, click Enqueue.
  3. Click Send Message. This input message is put on the SIMPLERROUTEDB_IN queue.
  4. In the Test Client, click the first Dequeue.
  5. Click Get Message to read a message from the SIMPLERROUTEDB_SNRSTAFF queue. This reply message confirms that Mr David Brown (employee: 000010) must be logged and recognised as a senior member of staff within the company. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000010</EmpNumber>
          	<FirstName>DAVID</FirstName>
          	<LastName>BROWN</LastName>
          	<YrsInService>10</YrsInService>
          	<AgeInYears>54</AgeInYears>
          	<WorkDept>D01</WorkDept>
    </EmpRecord>
  6. In the Test Client, click the second Dequeue.
  7. Click Get Message to read a message from the SIMPLERROUTEDB_ORDERCLOCK queue. This reply message confirms that Mr David Brown (employee: 000010) must be given a clock by his manager, which is awarded for ten years service in the company. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000010</EmpNumber>
          	<FirstName>DAVID</FirstName>
          	<LastName>BROWN</LastName>
          	<YrsInService>10</YrsInService>
          	<AgeInYears>54</AgeInYears>
          	<WorkDept>D01</WorkDept>
    </EmpRecord>

Running the SimplifiedDBRouting message flow with the test message that is in bypassdbretrievenode_keynotfound.mbtest

The SimplifiedDBRouting message flow compares employee details, that are given in the input message, with the details of their manager, that are acquired from a database lookup.

To run the SimplifiedDBRouting message flow:

  1. In the Broker Development view, expand the Simplified Database Routing Message Flows project, double-click the bypassdbretrievenode_keynotfound.mbtest file to open it in the Test Client.
  2. In the Test Client, click Enqueue.
  3. Click Send Message. This input message is put on the SIMPLERROUTEDB_IN queue.
  4. In the Test Client, click Dequeue.
  5. Click Get Message to read a message from the SIMPLERROUTEDB_KEYNOTFOUND queue. This reply message confirms that Mr David Brown (employee: 000010) has an invalid work department value. As a result, the unmodified input message is routed to the keyNotFound queue. The following example shows the format of a reply message:
    <EmpRecord>
          	<EmpNumber>000010</EmpNumber>
          	<FirstName>DAVID</FirstName>
          	<LastName>BROWN</LastName>
          	<YrsInService>10</YrsInService>
          	<AgeInYears>54</AgeInYears>
          	<WorkDept>E00</WorkDept>
    </EmpRecord>

Back to sample home