Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

In an IBM MQ collection agent workflow there are four different UDRs created and sent. This requires one ore more agents containing APL code (Analysis or Aggregation) to be part of the workflow.

Collect and Process IBM MQ Message

If "dynamic initialization" has been configured, a configRequest, including an empty MQConnectionInfo UDR, is sent to an Analysis agent at startup. The Analysis agent populates the UDR with configuration info and returns it to the IBM MQ Collection agent.

For each collected message, the IBM MQ collection agent sends an InputMessage including an MQMessage UDR to the Analysis agent. If "Auto Remove" has been configured, the message is removed from the queue and a remMessage is sent to the agent.

Realtime workflow example - a message is collected from the IBM MQ collection agent

Dynamic Initialization

The following APL code example shows how to use dynamic initialization.

consume { 
        if (instanceOf(input, mq.MQConnectionInfo)) { 
            mq.MQConnectionInfo info = (mq.MQConnectionInfo) input; 
            info.Host = "mymqhost"; 
            info.Port = 1415; 
            info.ChannelName = "CHANNEL2"; 
            info.QueueManager = "mgr2.queue.manager"; 
        
            list<string> queues = listCreate(string); 
            listAdd(queues,"Q1.QUEUE"); 
            listAdd(queues,"Q2.QUEUE"); 
      
            info.Queues = queues; 
            udrRoute(info); 
        } 
    }

Process the MQ Message

The following APL code example shows how to process the IBM MQ message and remove it from the queue.

consume {
        if (instanceOf(input, mq.MQMessage)) { 
            mq.MQMessage msg = (mq.MQMessage) input;
            //Process the MQ Message
            handleResponse(msg);
            //Remove the message from the queue
            udrRoute(msg, "remMessage");
        }
    }

Send Messages to the IBM MQ Queue Manager

In the following figure the workflow forwards a message to an IBM MQ queue manager.

Workflow example - a message is sent to a queue manager

The following APL code example shows how to send an IBM MQ message to a queue.

mq.MQQueue queue;
    initialize {
        mq.MQQueueManagerInfo conUDR = udrCreate(mq.MQQueueManagerInfo);
        conUDR.ChannelName = "CHANNEL1";
        conUDR.Host = "10.46.100.86";
        conUDR.Port = 1414;
        conUDR.QueueManager = "mgr1.queue.manager";
        queue = mqConnect(conUDR, "Q1.QUEUE"); 
    }
    
    consume {
        mqStatus(queue);
        debug("Queue Depth: "+queue.CurrentDepth); 
        debug("Queue Max Depth: "+queue.MaxDepth);
        mq.MQMessage msg = udrCreate(mq.MQMessage);
        msg.Message = input;
        mqPut(queue, msg);
    }
    
    deinitialize {
        mqClose(queue);
    }
  • No labels