IBM MQ

Use the IBM® App Connect Enterprise Toolkit to configure message flow nodes that are converted from the IBM App Connect Professional MQ activities.

About this task

When you import an orchestration that contains MQ activities, the conversion utility creates a message flow with the MQInput, MQGet, and MQOutput nodes. See Table 1, for information on which nodes are used for each of the activities.

Table 1. IBM App Connect Professional IBM MQ activities and the corresponding IBM App Connect Enterprise message flow nodes
IBM App Connect Professional activity IBM App Connect Enterprise node
Get message

MQInput node

Put message

MQOutput node

Poll message

MQGet node

Differences between IBM App Connect Professional and IBM App Connect Enterprise
  • In IBM App Connect Professional, the default connection is remote, and you don't need to select the connection type. However, in IBM App Connect Enterprise, you must specify the connection type as either Local, IBM MQ Client (Remote), or CCDT File.
  • In IBM App Connect Professional, the username field is mandatory for IBM MQ connections. Whereas in IBM App Connect Enterprise, providing credentials is optional.

Connecting IBM MQ

About this task

To connect to IBM MQ, you can follow two main approaches:
  1. IBM MQ connection
  2. Policy project

IBM MQ connection

Procedure

  1. Select the IBM MQ node (MQInput node or MQGet node or MQOutput node).
  2. Go to the IBM MQ connection tab, then connection property. Select the connection from the drop-down list.
    Interface for specifying MQ connection properties. MQ Client connection properties is highlighted in the drop-down list
    1. Provide the destination queue manager name, queue manager host name, listener port number, and channel name.
      Interface for specifying MQ Input node properties with input boxes filled in
    Security identity is not mandatory for IBM MQ Connections and they can work without specifying it. If you want to provide one, follow these steps.

Creating the security identity (DSN) for an IBM MQ connection in IBM App Connect Enterprise

Procedure

  1. Open the IBM App Connect Enterprise Console or command prompt:
    1. Go to the server or workstation where IBM App Connect Enterprise is installed.
    2. Open the console on the server where IBM App Connect Enterprise instance is running.
  2. Define the Security Identity (DSN):
    1. Run the mqsisetdbparms command to create a security identity for your WebSphere MQ connection in the IBM App Connect Enterprise console.
      The syntax looks like this:
      mqsisetdbparms --work-dir <workDir> -n mq::<securityId> -u <userName> -p <password>

      Example

      mqsisetdbparms --work-dir C:\ACE12NODEWS\TEST_SERVER -n mq::mqdsn -u <MQ_Username> -p <MQ_Password>
      Edit the command to replace the following items:
      • <workDir> with the working directory of your integration server. For example, C:\ACE12NODEWS\TEST_SERVER.
      • <securityId> with a unique name you define for the security identity (DSN). For example, mqdsn.
      • <MQ_Username> with the IBM MQ username.
      • <MQ_Password> with the IBM MQ password.

      After you run the command successfully, restart your integration server in IBM App Connect Enterprise to apply the changes.

      Right-click the integration server (for example TEST_SERVER) in the toolkit and select restart.

      Interface showing context window with options for interacting with TEST_SERVER

IBM MQ Policy Project

About this task

IBM MQ Policy project is used to configure and manage IBM MQ connectivity for message flows. you can easily maintain, reuse, and update connection details without modifying the code or redeploying the application.

Create the policy project by following these steps:

Procedure

  1. Go to FileNew → select policy project.
  2. Name the file.
    For example, MQPOLICY
  3. Right-click the project and select NewPolicy.
  4. Choose the type and template as MQEndpoint.
  5. Select connection from drop-down menu
    Interface for specifying MQ policy project connection. CLIENT is highlighted from drop-down list

Example

Screenshot showing example configuration properties. Connection value: CLIENT is highlighted
Deploy Policy Project:
  • Save the policy project after creation.
  • Deploy it to the integration server before you deploy the main project.
Note:
  • The properties that are set in the policy override the corresponding properties that are set on the IBM MQ Connection tab.
  • If an MQEndpoint policy is not specified, then property values that are set on the IBM MQ Connection tab are used.
  • Specify the name of the policy project and the policy in the format {policyProjectName}:PolicyName.

Example:Screenshot of example policy property

MQInput, MQGet and MQOutput nodes for Get, Put and Poll message activities.

About this task

In IBM App Connect Enterprise, Get message activity, which retrieves messages from an IBM MQ queue, can be achieved through the MQGet node. The Put message activity, which processes the retrieved message and writes it to another IBM MQ queue, can be achieved through the MQOutput node. The Poll message activity, which immediately processes a message when it arrives in the queue, can be achieved with the MQInput node.

An example message flow looks like this:

MQInput node → MQGet node → MQOutput node

Procedure

  1. Provide IBM MQ connection details:
    1. Configure the MQInput node and MQOutput node with the required IBM MQ connection details, such as:
      Screenshot of example MQ connection set up with properties specified
  2. Configure the MQInput node:
    1. In the MQInput node, specify the queue name from which the message flow receives messages. It immediately processes a message as it arrives in the queue.
    For example, MyQueueScreenshot of example queue name
  3. Configure the MQGet node:
    1. In the MQGet node, specify the queue name from which this node retrieves messages.
      For example, MQGetQueueScreenshot of example queue name
  4. Configure the MQOutput node:
    1. In the MQOutput node, specify the destination queue where the output messages are sent.
      For example local.Screenshot of example queue name
  5. Deploy and run the flow:
    1. Deploy the configured message flow in your IBM App Connect Enterprise environment.
    2. Start the flow to make it active.
  6. Test the Flow Using IBM MQ Explorer:
    1. Open IBM MQ Explorer and put a test message into the input queue (MyQueue).
    The message flow processes the message, passing through the MQInput node, MQGet node, and then, the MQOutput node to send it to the output queue (local).
  7. Verify the message in IBM MQ Explorer:
    1. In IBM MQ Explorer, browse the output queue (local) to confirm that the message was successfully transferred.
    2. Check that the input message was processed correctly and delivered to the destination queue.

Example

  • Input Queue Name: MyQueue
  • Output Queue Name: local

Retrieving data from a previous node to use it in the IBM MQ node

About this task

In IBM App Connect Professional, data from the previous node is accessed by using Map Inputs and Map Outputs in the Checklist, whereas IBM App Connect Enterprise, a Compute node is used to access data from the previous node.

The input JSON looks like this:

{

    "Name": "John",

    "Age": 30

}

The Compute node code looks like this:

CREATE COMPUTE MODULE MQMsgFlow_Compute

CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

    -- Declare variables

    DECLARE inputJson CHARACTER;

    DECLARE name CHARACTER;

    DECLARE age INTEGER;

    -- Initialize the output tree

    SET OutputRoot = NULL;

    -- Copy the MQMD header from InputRoot to OutputRoot

    SET OutputRoot.MQMD = InputRoot.MQMD;

    SET OutputRoot.MQMD.Format = 'MQSTR';

    -- Parse the JSON data from InputRoot

    SET inputJson = CAST(InputRoot.JSON.Data AS CHARACTER);


    -- Extract fields from JSON

    SET name = InputRoot.JSON.Data.Name;

    SET age = InputRoot.JSON.Data.Age;

    -- Build the XML structure in the XMLNSC domain

    SET OutputRoot.XMLNSC.Message.Person.Name = name;

    SET OutputRoot.XMLNSC.Message.Person.Age = age;

    RETURN TRUE;

END;

END MODULE;

The output XML looks like this:

<Message>

    <Person>

        <Name>John</Name>

        <Age>30</Age>

    </Person>

</Message>

IBM MQ Explorer result:Screenshot of MQ Explorer result. Output XML is highlighted

Configuring message details in IBM MQ

About this task

In IBM App Connect Professional, you can directly configure the Payload Data Type and Message Type properties under checklist → configure → message details. However, in IBM App Connect Enterprise, these properties can be set by using a Compute node.

The Payload data type can be configured by editing the following items:

Binary - set MQMD.Format to ' ' (empty or 8 spaces)

String - set MQMD.Format to MQSTR;

Message Type:

Datagram - MQMD.MsgType = MQMT_DATAGRAM;

Example

Table of message type values and their meanings

The Compute node code looks like this:

CREATE COMPUTE MODULE mqflowsample_Compute

CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

    -- Pass input message to the output

    SET OutputRoot = InputRoot;

    -- Ensure the MQMD header exists

    IF OutputRoot.MQMD IS NULL THEN

        CREATE FIELD OutputRoot.MQMD;

    END IF;

    -- Set MQMD.Format to Binary

    SET OutputRoot.MQMD.Format = '        '; --or empty

    -- Set MQMD.MsgType to Datagram

    SET OutputRoot.MQMD.MsgType = MQMT_DATAGRAM;

    RETURN TRUE;

END;

END MODULE;

In the flow exerciser, you can view the MQMD properties, including Format and MsgType.Screenshot showing a table of MQMD properties. MsgType, INTEGER, 8 is highlighted.