Develop a message flow for populating a target from a database

Before you start
This is the seventh stage of the scenario to perform simple message enrichment. This topic demonstrates how to develop a message flow for populating a target from a database. It also involves developing a corresponding message model and instance documents.
  1. Create a database called MAPDB and create a table called TRANSACTION, which has the following columns:
    ACCOUNT        VARCHAR(12)
    TDATE                DATE
    VALUE               DECIMAL(8,2)
  2. Populate the database with the values shown:
    '12345678901', '2005-04-25', -14.25
    '12345678901', '2005-04-25', 100.00
    '12345678901','2005-05-15', 2891.30
    '12345678901','2005-06-11', -215.28
  3. Create a Windows ODBC Data Source Name for the database and then register the database with the Configuration Manager by clicking File > New > RDB Definitions File.
  4. In the COMPLEX message definition, in namespace www.complex.net, create a message called addev4in, which has the following structure:
    addev4in
       account             (xsd:string) local element
       tdate                 (xsd:date) local element
  5. In the COMP2 message definition, in namespace www.comp2.net, create a message called addev4out, which has the following structure:
    addev4out
       account             (xsd:string) local element
       tdate                 (xsd:date) local element
       value                 (xsd:decimal) local element, minOcc=0, maxOcc=-1
  6. Create a message flow called addev4, which contains the following mapping: MQInput > Mapping > MQOutput.
  7. Open the map and select addev4in as the source and addev4out as the target.
  8. Map the input to outputs as shown:
    account --- account
    tdate --- tdate
  9. In the Spreadsheet pane, right-click the target value and click Select Data Source.
  10. Select MAPDB from the dialog box and click Finish.
  11. In the top pane, expand the MAPDB tree and wire the values as shown:
    VALUE  --- value
  12. In the Spreadsheet pane, select the target $db:select and change fn:true() to: $db:select.MAPDB.SCHEMA.TRANSACTION.ACCOUNT=$source/comp:addev4in/account and $db:select.MAPDB.SCHEMA.TRANSACTION.TDATE=$source/comp:addev4in/tdate
  13. Expand the Properties tree and set the following values:
    MessageType     |    'addev4out'
  14. Set the data source property for the Mapping node to MAPDB.
  15. Create the following instance messages with appropriate RFH2 headers:
    <comp:addev4in xmlns:comp="http://www.complex.net">
    <account>12345678901</account>
    <tdate>2005-05-15</tdate>
    </comp:addev4in>
    <comp:addev4in xmlns:comp="http://www.complex.net">
    <account>12345678901</account>
    <tdate>2005-04-25</tdate>
    </comp:addev4in>
You have created the following resources:
Now deploy the message set and message flow.

Deploy the message set and message flow

This is the eighth stage of the scenario to perform simple message enrichment. This topic demonstrates how to deploy the message set and message flow and run the instance messages through the broker.
  1. Create a bar file called addev4.
  2. Add the message set MAPPING3_COMPLEX_messages and the message flow addev4 to the bar file.
  3. Deploy the bar file to the broker.
  4. Put the instance documents on the input queue.
The output messages look like this:
<c2:addev4out xmlns:c2="http://www.comp2.net" xmlns:comp="http://www.complex.net" >
<account>12345678901</account>
<tdate>2005-05-15</tdate>
<value>2891.3</value>
</c2:addev4out>