Saturday, 8 March 2014

Dynamic FileTransfer Using File Nodes

Step:1
Create a message flow with below properties on FileInputNode and no properties to be specified at FileOutputNode


Step:2
In JavaComputeNode we should create below processing logic

String FileName=(inAssembly.getLocalEnvironment().getRootElement().getFirstElementByPath("File/Name")).getValueAsString();

MbElement FWD=outAssembly.getLocalEnvironment().getRootElement().createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Destination",null);

MbElement File=FWD.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"File",null);

File.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Directory","C:/Users/miracle/Desktop/TEST/TARGET");


File.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Name",FileName);

Step:3
Connect the output terminal of the JCN to input terminal of FileOutputNode and save the flow and deploy the flow under any execution group of a Broker.

Step:4
The tree structure when the flow was at the below break point should look like below


Step:5
The tree structure when the flow was at the below break point should look like below

Step:6
Now you can see the file being present at the target directory.

Source Directory consists of mqsiarchive,mqsibackout,mqsitransitin folders.
Target Directory consists of mqsitransit

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