(V10.0.0.2) Using a Mapping node to graphically access a Lookup table that is stored in the Global Cache

IBM Knowledge Center

Learn how to use a Mapping node to graphically access a Lookup table that is stored in the Global Cache by exploring this simple example.

Import the application

Click Import to import the application into your workspace. Note: You must have IBM Integration Toolkit Version 10.0.0.2 or later.

The LookupTable_UsingMappingGlobalCache application is now shown in the Application Development view of your workspace. The LookupCountyFullName message flow is opened in the Message Flow editor.

The LookupCountyFullName message flow contains a number of nodes:

  • HTTP Input: An Input node that receives an input message that contains an abbreviated county name.
  • LookupCountyFullName: A Mapping node that accesses the global cache to interrogate the Lookup table for the full county name.
  • FoundCountyFullName: A Route node that determines the path that the message should take depending on whether the full county name was retrieved from the global cache.
  • File Read: A FileRead node that reads the file that contains the Lookup table data.
  • LoadCache: A Mapping node that loads the Lookup table data into the global cache.
  • HTTP Reply: A Reply node that returns a message that contains the full county name.

You can explore the configuration of these nodes later in the tutorial.

Preparing to run the application

Perform the following steps to prepare your environment to run the LookupTable_UsingMappingGlobalCache application.

  1. Enable the embedded global cache by running the following command from the command line or IBM Integration Console:
    mqsichangebroker integrationNodeName -b default
    where integrationNodeName is the name of your integration node and default is the name of your integration server. Note: The integration node must be running IBM Integration Bus Version 10.0.0.2 or later.
  2. Setup the location of the lookup table initialization data file by completing one of the following steps:
    • On Windows: Create the input directory C:\temp.
    • On Linux: Change the Input directory property of the 'File Read' node to a Linux path.
  3. Copy the CountyAbbrNames.csv file from the 'Other Resources' folder in the LookupTable_UsingMappingGlobalCache application to the input directory.

Next you will use the Flow exerciser to send HTTP requests to the message flow.

Follow these steps to run the application

Open the LookupCountyFullName message flow from the application and complete the following steps:

  1. Click the Flow Exerciser icon to start recording the message path through the flow.
  2. Click the Send Message icon to select the first message to send to the flow.
  3. Select the 'Berks' input message, and click Send.
    The request message is sent to the HTTP Input node, and the response message containing the full name, 'Berkshire', is received.
  4. Close the Send message dialog.
    The message path is automatically highlighted on the message flow. Note: The message path shows that the message was sent through the 'File Read' and 'LoadCache' Mapping nodes. Because the Lookup table was not in the Global Cache, the 'LookupCountyFullName' Mapping node cannot find a match.
  5. Click on any connection to see the data that passed through that connection.
  6. Click the Send Message icon again, to select the 'Hants' message and send it to the flow by clicking Send.
  7. Review the received message and close the Send message dialog to see the message path.
    Note: The message path shows that the message was sent directly to the 'HTTP Reply' node. Because the Lookup table is in the Global Cache, the 'LookupCountyFullName' Mapping node found a match and set the 'CountyFullName'.

If you restart the integration node, or issue a mqsicacheadmin command to clear the Global Cache, the next message is sent through the 'File Read' and 'LoadCache' Mapping nodes again.

The following optional steps help you explore and understand the application

The LookupCountyFullName message flow uses an HTTP Input node to receive a JSON message that contains a 'CountyAbbr' value. The 'CountyAbbr' value is used in the 'LookupCountyFullName' Mapping node to lookup the replacement full county name from the Global Cache.

  1. Double click the 'LookupCountyFullName' Mapping node to open the associated Graphical Data Map that includes the 'Cache Get' transform.
  2. Click the 'Local map' to enter the nested mapping. Note: The value for the input element, 'CountyAbbr', is placed in the 'Environment' so that it is not overwritten by the data that is retrieved from the 'CountyAbbrNames.csv file.
  3. Click the 'Cache Get' transform to enter the nested mapping for the transform and review the mapping of the 'Key' that is used to select the entry in the Lookup table. Note: 'MapName' is set by using a CustomXPath transform to configure a user-defined property.
  4. Click the up arrow to exit the nested mapping, then click the 'Cache Return' transform to enter the nested mapping for the transform and review the mapping from the 'Value' that is returned from the Global Cache.
  5. Click the 'Move' transform and view the Condition tab in the Properties, to see that the 'Value' element is created only if an entry is found in the Global Cache.
  6. Return to the message flow editor.
    The 'FoundCountyFullName' Route node checks for the presence of the 'CountyFullName' value:
    • If the 'CountyFullName' value exists, the message is routed directly to the 'HTTP Reply' node.
    • If the 'CountyFullName' value does not exist (for example, if the Lookup table in the Global Cache is not populated), the message is routed to the 'File Read' node. The 'File Read' node retrieves name-value pairs from a comma-separated-values file that is parsed by using a DFDL CSV model. The name-value data is passed to the 'LoadCache' Mapping node, where the data is loaded into a Lookup table in the Global Cache. The 'LoadCache' mapping node also sets the 'CountyFullName' value in the output message.
  7. Double click the 'LoadCache' Mapping node to open and explore the map and review the use of the 'Cache Put' transform within the 'For each' transform. Note: The value of 'CountyFullName' for the current lookup request is taken directly from the data that is read from the comma-separated-values file.