Friday, February 8, 2013

Hello Message Broker JAVA API!!!

Prior to MB 8, Message Broker API (CMP API) is used to develop java applications to administrate Broker and its resources but we can’t develop or modify message flow applications.
In MB 8, we can develop/modify message flow applications using java and there is no need of Message Broker Toolkit to be installed in our machine that means from now onwards we can develop message in an environment which doesn’t support Message Broker Toolkit (Unix, z/OS)
We need only the jar file “ConfigManagerProxy.jar” and compatible JRE to develop message flow.
This post gives overview of how to create simple message flow using Message Broker Java API.
Configure our windows environment to develop java applications:
1. Add the jar file to CLASSPATH environment variable   
    set CLASSPATH = %install_dir%\classes\ConfigManagerProxy.jar
2. Verify using below command
    echo %CLASSPATH%

Important packages:
Package com.ibm.broker.config.appdev: This package has set of classes to create/modify/read/write/set properties of message flow
Package com.ibm.broker.config.appdev.nodes: This packages has set of classes of all built-in nodes
Create new message flow:
The below sample JAVA application shows how to create new message flow, add nodes, create connections, set properties and save the created message flow.

 


Compile and run the java code. The code will generate the message flow in the same directory where the .class resides.
Copy the message flow that is generated by this code in the Message broker toolkit and the flow design will be as below.

Load and Modify existing message flow:

The below sample JAVA code shows how to load , rename and save existing message flow.

File msgFlow  = new File(“LOAD_MSGFLOW.msgflow”);
MessageFlow mf1  = FlowRendererMSGFLOW.read(msgFlow);
String NewFlowName  = “LOADED_MSGFLOW_RENAMED”;
mf1.setName(NewFlowName);
FlowRendererMSGFLOW.write(mf1, “.”);

3 comments:

  1. How do you compile all this without the toolkit? How do you create a the bar file with compiled message flow (CMP) and message sets (.dictionary, .rm and .xsdzip)?

    ReplyDelete
  2. This API has a Class FlowRendererBAR which helps us to create a bar but it won't actually compile message broker artifacts. it is similar to mqsipackagebar comment. Class FlowRendererCMF used to compile only message flow but we don't have any class to complie message sets (.dictionary, .rm and .xsdzip)

    ReplyDelete
  3. Hello I HAVE GOOD KNOWLEDGEIN JAVA?J2EE worked as sr programmer, iwant to get into WMB/WMQ
    I need u r openion an d help for this. I heard that there is a ESQL coding , as a java programmer i am familier with java , can i develop the code in java instead of esql. i f possible pls provide me some links to learn
    thanks in advance

    ReplyDelete