Friday, 19 February 2016


           Using the Exception plug-in node in IIB V9.0



Introduction
The Exception plug-in node requires IBM® Integration Bus V9 or later, and runs on both
Microsoft® Windows® and Linux®. The plug-in node consists of two parts, a run-time JAR file
(
ExceptionRuntime.jar), and a design-time Toolkit plug-in (ExceptionJavaPlugin.jar), which
provide the node for use in message flows.

Installing
To install the run-time component:
1.
Download ExceptionPlugin.zip at the bottom of the article.
2. Unzip ExceptionPlugin.zip.
3. Copy
runtime/ExceptionRuntime.jar to all of the machines running brokers that are required
to run the node. Place the JAR file in
<IBM Integration Bus Runtime Install Directory>/
plugins
:
• Windows:
C:\Program Files (x86)\IBM\MQSI\9.0.0.0\jplugin
• Linux: /opt/ibm/mqsi/9.0.0.1/jplugin
To install the design-time component:
1. Unzip the plug-in zip file.
2. Copy
toolkit/ExceptionJavaPlugin.jar and place in <IBM Integration Bus
Toolkit Install Directory>/plugins
. For example: C:\Program Files (x86)\IBM
\IntegrationToolkit90\plugins
.
developerWorks® ibm.com/developerWorks/
Using the Exception plug-in node in IBM Integration Bus Page 2 of 7

Uninstalling
1. Stop IBM Integration Bus and close the Toolkit.
2. Remove the runtime JAR file
ExceptionRuntime.jar from the <IBM Integration Bus Install
Directory>/plugin
directory.
3. Remove the toolkit JAR file
ExceptionJavaPlugin.jar from the <IBM Integration Bus
Toolkit Directory>/plugins
directory.
4. Start IBM Integration Bus and open the Toolkit.

How the node works
The Exception node parses the ExceptionTree generated during message flow execution, and
retrieves details such as Exception Code, Text, and Details. The following example shows how you
can use the node in a message flow:





In this message flow,
HTTPRequest throws a socket exception, and the Exception node retrevies the
generated exception details.
Here is the flow execution in Debug mode. Before the Exception node:
After the Exception node. The Exception details are captured in
Enviornment.
ibm.com/developerWorks/ developerWorks®
Using the Exception plug-in node in IBM Integration Bus Page 3 of 7


Conclusion
IBM Integration Bus Exception node makes it much easier to capture exception details in a
message flow, and avoids redundant code that you must reconfigure for every project.

                          Sequence Node in Message Broker


Step 1:- Create a flow with MQInput Node,Sequence Node & MQOutput Node as follows


Step 2:- Sequence Node configuration


Step 3:- Provide the input like this :-
<doc><grp>AJAY</grp></doc>

Step 4:- The result would be like this on first run
<doc><grp>AJAY</grp><seq>0</seq></doc>

Next time you put the same input again,the result would be

<doc><grp>AJAY</grp><seq>1</seq></doc>

The sequence keeps on increasing like this..

Simple flow using JavaCompute Node in Message Broker 


Step 1:- Create a flow with MQInput Node,JavaCompute Node & MQOutput Node as follows.

Step 2:- Then paste the following code into JCN.

import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.MbElement;
import com.ibm.broker.plugin.MbException;
import com.ibm.broker.plugin.MbMessage;
import com.ibm.broker.plugin.MbMessageAssembly;
import com.ibm.broker.plugin.MbOutputTerminal;
import com.ibm.broker.plugin.MbUserException;
public class Java_Compute_Node_JavaCompute extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly inAssembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
//MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage inMessage = inAssembly.getMessage();
MbMessageAssembly outAssembly = null;
try {
// create new message as a copy of the input
MbMessage outMessage = new MbMessage(inMessage);
outAssembly = new MbMessageAssembly(inAssembly, outMessage);
MbElement xml = outAssembly.getMessage().getRootElement().getLastChild();
MbElement emp = xml.getFirstChild();
emp.setName("Student");
MbElement sno = emp.getFirstChild();
sno.setName("sno");
MbElement sname = sno.getNextSibling();
sname.setName("sname");
sname.setValue(sname.getValue().toString().toUpperCase());
out.propagate(outAssembly);
} catch (MbException e) {
// Re-throw to allow Broker handling of MbException
throw e;
} catch (RuntimeException e) {
// Re-throw to allow Broker handling of RuntimeException
throw e;
} catch (Exception e) {
// Consider replacing Exception with type(s) thrown by user code
// Example handling ensures all exceptions are re-thrown to be
// handled in the flow
throw new MbUserException(this, "evaluate()", "", "", e.toString(),
null);
}
// The following should only be changed
// if not propagating message to the 'out' terminal
out.propagate(outAssembly);
}
}


Step 3:- Provide the input as follows:-
<Employee><eno>1</eno><ename>ajay</ename></Employee>

Step 4:- The result would be like 
<Student><sno>1</sno><sname>AJAY</sname></Student>