|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Java Plug-in node help |
« View previous topic :: View next topic » |
Author |
Message
|
pfaulkner |
Posted: Fri Jun 27, 2003 11:27 am Post subject: Java Plug-in node help |
|
|
Master
Joined: 18 Mar 2002 Posts: 241 Location: Colorado, USA
|
I am trying to write my first Java Plug-in node and need a little help.
It should be a very simple node, all I need it to do is get the QMgr Name.
This is my code so far:
// -classpath d:\MQSeries\java\lib\com.ibm.mq.jar;d:\MQSI\classes\jplugin.jar
import com.ibm.broker.plugin.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class GetQMgrNameNode extends MbNode implements MbNodeInterface
{
public GetQMgrNameNode() throws MbException
{
createInputTerminal("in");
createOutputTerminal("out");
createOutputTerminal("failure");
}
public void evaluate(MbMessageAssembly assembly, MbInputTerminal in)
throws MbException
{
// Get Broker's Queue Manager Name
//String qmgrname = getBroker().getQueueManagerName();
MbOutputTerminal out = getOutputTerminal("out");
out.propagate(assembly);
}
//-----------------------------------------
public static String getNodeName()
{
return "GetQMgrNameNode";
}
//-----------------------------------------
public String getQMgrName() throws MbException
{
return getBroker().getQueueManagerName();
}
}
Do I need to do anything else?
Also, how do I actually use the node to retrieve the QMGr from my flow?
thanks for any help. The manuals don't seem very clear. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 27, 2003 12:45 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You're going to want to change the output assembly in some way, probably by creating an element in the Root tree or in the Environment or Local Environment tree, that will contain the value you've retrieved from getBroker().getQueueManagerName();
Then you can use that from ESQL. |
|
Back to top |
|
 |
pfaulkner |
Posted: Mon Jun 30, 2003 7:31 am Post subject: |
|
|
Master
Joined: 18 Mar 2002 Posts: 241 Location: Colorado, USA
|
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 30, 2003 7:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
pfaulkner wrote: |
How do I do that? |
Using Java, of course!
Here's some code. It should populate Environment.Variables.QueueManagerName with the value returned from getQueueManagerName(). I haven't tested it, so use at your own risk, and it's probably uglier than it should be.
Code: |
String qmgrname = getBroker().getQueueManagerName();
MbElement envElement = outAssembly.getGlobalEnvironment().getRootElement();
MbElement varElem = envElement.getFirstElementByPath("./Variables");
if (varElem == null) {
varElem = envElement.createElementAsLastChild(MbElement.TYPE_NAME);
varElem.setName("Variables");
}
MbElement qmnElem= varElem.getFirstElementByPath("./QueueManagerName");
if (qmnElem == null) {
qmnElem = varElem.createElementAsFirstChild(MbElement.TYPE_NAME);
qmnElem.setName("QueueManagerName");
MbElement qmnElemVal = qmnElem.createElementAsFirstChild(MbElement.TYPE_VALUE);
qmnElemVal.setValue(qmgrname);
} else {
qmnElem.setValue(qmgrname);
} |
|
|
Back to top |
|
 |
pfaulkner |
Posted: Mon Jun 30, 2003 8:03 am Post subject: |
|
|
Master
Joined: 18 Mar 2002 Posts: 241 Location: Colorado, USA
|
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 30, 2003 10:00 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I forgot some important bits - making a copy of the input assembly so you can modify the pieces of it.
Code: |
MbMessage outMsg = new MbMessage(assembly.getMessage());
MbMessage outLEnv = new MbMessage(assembly.getLocalEnvironment());
MbMessage outEnv = new MbMessage(assembly.getGlobalEnvironment());
MbMessage outExc = new MbMessage(assembly.getExceptionList());
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,outLEnv,outEnv,outExc,outMsg); |
And then propogate the outAssembly instead of the assembly you were passed in your evaluate. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|