The MQOutput node can send multiple messages that form a WebSphere® MQ message group. Configure a Compute or JavaCompute node to set the MQMD fields to specify message group options.
DECLARE MSGNUM INT 0;
DECLARE MSGTOTAL INT 5;
WHILE MSGNUM < MSGTOTAL DO
SET MSGNUM = MSGNUM + 1;
CALL CopyMessageHeaders();
-- Manually set the groupId since we cant ask the queue manager to generate one.
-- the UUIDASBLOB function could be used here to generate one, but this must be done
-- outside the loop to keep the same groupId throughout!
SET OutputRoot.MQMD.GroupId = X'000000000000000000000000000000000000000000000001';
SET OutputRoot.MQMD.MsgSeqNumber = MSGNUM;
SET OutputRoot.MQMD.MsgFlags = MQMF_MSG_IN_GROUP;
IF (MSGNUM = MSGTOTAL) THEN
SET OutputRoot.MQMD.MsgFlags = MQMF_LAST_MSG_IN_GROUP;
END IF;
SET OutputRoot.XML.TestCase = MSGNUM;
PROPAGATE;
END WHILE;
RETURN FALSE;
public class mq_group_java_JavaCompute extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
int MSGTOTAL = 5;
for(int MSGNUM = 1 ; MSGNUM <= MSGTOTAL;MSGNUM++){
MbMessage newMessage = new MbMessage();
MbElement root = newMessage.getRootElement();
MbElement mqmd = root.createElementAsFirstChild("MQMD");
mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,
"GroupId", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1});
mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "MsgSeqNumber", MSGNUM);
if (MSGNUM == MSGTOTAL){
mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,
"MsgFlags", 16); // MQMF_LAST_MSG_IN_GROUP 0x00000010
}
else{
mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,
"MsgFlags", 8); // MQMF_MSG_IN_GROUP 0x00000008
}
MbElement xmlnsc = root.createElementAsLastChild("XMLNSC");
MbElement body = xmlnsc.createElementAsLastChild(MbElement.TYPE_NAME,"TestCase",null);
body.setValue(MSGNUM);
MbMessageAssembly newAssembly = new MbMessageAssembly(assembly,newMessage);
out.propagate(newAssembly);
}
}
}
If the message flow is sending multiple messages from one input message, it can create a GroupId value, increment the MsgSeqNumber value, and set the MsgFlags field. The examples of ESQL and Java code show how you can set these values. However, if the message flow is sending multiple messages from more than one input message, it must store the GroupId and MsgSeqNumber values between flow instances, which is achieved by using shared variables.
For
more information about message grouping, see Message groups in the
WebSphere MQ Version 7.5 product documentation online. For more information
about WebSphere MQ fields, see
MQMD - Message descriptor of the
WebSphere MQ Version 7.5 product documentation online.