Wednesday, 26 February 2014

Trigger the Flow with TimerNode and Place Message to Queue

Step:1
Configure the properties of TimeroutNotification Node as below



Step:2
In JavaComputeNode we should create below processing logic

                        MbMessage inMessage = inAssembly.getMessage();
       MbMessageAssembly outAssembly = null;

// Create new message as a copy of the input to change the inassembly that is obtained from timer node

MbMessage outMessage = new MbMessage(inMessage);
outAssembly = new MbMessageAssembly(inAssembly, outMessage);
MbElement root=outAssembly.getMessage().getRootElement();
MbElement body=root.getFirstChild();

                        UUID uid=UUID.randomUUID();
String uuid=uid.toString().substring(0,24);

//Creating MQMD Header with below properties to Place message in to Queue

MbElement mqmd=body.createElementAfter("MQMD");
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Version",Integer.parseInt("2"));
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Format","MQSTR");
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"MsgId",uuid.getBytes());
//Creating message with MbElement.TYPE_NAME_VALUE for timer node will not work out here
//MbElement xmlnsc=root.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"XMLNSC",null);
//MbElement XMLROOT=xmlnsc.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"TEST",null);
//XMLROOT.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Message","Success");

//Create message using MbXMLNSC.PARSER_NAME, MbXML.ELEMENT
MbElement xmlnsc=root.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement XMLROOT=xmlnsc.createElementAsFirstChild(MbXML.ELEMENT,"TEST",null);
XMLROOT.createElementAsFirstChild(MbXML.ELEMENT,"Message","Success");

Step:3
Give Queue Name to the MQOutputNode