ibm-mqibm-integration-bus

Route messages to different message queues in IBM MQ based on MQRFH2 and USR properties


Would appreciate if anyone is able to assist/provide some sort of a guide/tutorial for using IBM IIB (Integrated Toolkit) and IBM MQ, making use of MQ Input Node, Compute Node and MQ Output Node, such that when a message is put on the input queue, it will be routed to an output queue based on the MQRFH2 headers and USR properties set/defined in the compute node (ESQL file)

E.g. If MQRFH2/USR = 1, route message to Queue 1, IF MQRFH2/USR = 2, route message to Queue 2, etc.

Thanks in advance.


Solution

  • Please read Accessing the MQRFH2 header and Populating Destination in the local environment tree.

    Then you could write your ESQL like this: (assuming the RFH2 routing variable is named Ker)

    CREATE COMPUTE MODULE Routing_Compute
        CREATE FUNCTION Main() RETURNS BOOLEAN
        BEGIN
            SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName =
                CASE InputRoot.MQRFH2.usr.Ker
                    WHEN '1' THEN 'Q1'
                    WHEN '2' THEN 'Q2'
                    ELSE 'Q3'
                END;
            RETURN TRUE;
        END;
    END MODULE;
    

    Remember to change the default node configuration like this:

    Example: If input message header Ker has value 2, then it will be routed to queue Q2.