Quotes

Thursday, October 27, 2016

How to call jar using ESQL and Java Compute Node in IIB/WMB

Compute Node in IIB :-
The Compute node is contained in the Transformation drawer of the palette. The following can be achieved using the Node:-
  • Transformation of message
  • Routing
  • Build a new message
Java Compute Node in IIB
The JavaCompute node is contained in the Transformation drawer of the palette. The following can be achieved using the Node:-
  • Use Java to examine an incoming message and, depending on its content, propagate it unchanged to one of the two output terminals of the node. The node behaves in a similar way to a Filter node, but uses Java instead of ESQL to determine which output terminal to use.
  • Use Java to change part of an incoming message and propagate the changed message to one of the output terminals.
  • Use Java to create and build a new output message that is independent of the input message.
  • Use Java to create a map in a global cache, and to add and retrieve data from that map. By storing data in the global cache, that data is available to other JavaCompute nodes or message flows.
How to consume jar using ESQL and Java Compute Node
  1. Switch to java View :-
  2. File => New => Java Project
  3. Add jar to Libraries(External Libraries)
5.Add the JAR files to the following directory:
  • ForWindows
workpath\shared-classes
  • ForLinux, UNIX and z/OS
workpath/shared-classes
Example :-  C:\ProgramData\IBM\MQSI\shared-classes
Note : Jar files can also be placed in specific folders to be accessed by particular broker.
6. Add reference of the java project to the Application
7. Restart the broker.
The above steps are common for both
How to call the function from COMPUTE NODE :-
  1. Now in the compute node, create a method which will refer to the method in jar.
CREATE FUNCTION Multiply(IN input1 INTEGER, IN input2 INTEGER)    RETURNS INTEGER       LANGUAGE JAVA EXTERNAL NAME “sample.calculate.Result”;
  1. Now call the function from the main finction :-
SET Multresult = Multiply(2,3);

How to call the function from JAVA COMPUTE NODE :-
  1. Import the class(for example Result Class in this case)
  import sample.calculate.Result;
  1. Now create an object of the class to call the method.
Result obj1 = new Result();
String Res = obj1. Multiply(2,3);

No comments:

Post a Comment