Author |
Message
|
rsandoz |
Posted: Tue Dec 05, 2006 8:15 am Post subject: Propagate to Label Java |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
I am currently using MB6 with a JavaComputeNode. Is there a way to do PROPAGATE TO LABEL from Java? I also explored using terminals to do something similar. All I have are terminals out, failure and alt. Is there a way to add another terminal? (I noticed the method createOutputTerminal) |
|
Back to top |
|
 |
Bill.Matthews |
Posted: Tue Dec 05, 2006 11:51 am Post subject: Re: Propagate to Label Java |
|
|
 Master
Joined: 23 Sep 2003 Posts: 232 Location: IBM (Retired)
|
rsandoz wrote: |
I am currently using MB6 with a JavaComputeNode. Is there a way to do PROPAGATE TO LABEL from Java? I also explored using terminals to do something similar. All I have are terminals out, failure and alt. Is there a way to add another terminal? (I noticed the method createOutputTerminal) |
The ability to do a Propagate to LABEL from a JavaCompute node was added to the Broker runtime in FP3 (v6.0.0.3). _________________ Bill Matthews |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 05, 2006 11:57 am Post subject: Re: Propagate to Label Java |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Bill.Matthews wrote: |
The ability to do a Propagate to LABEL from a JavaCompute node was added to the Broker runtime in FP3 (v6.0.0.3). |
It appears that the InfoCenter has not been updated to indicate how this is done, at least in the Java API documentation for the propagate method.
Nor does it appear to be in the readme.html.
Care to share some code, Bill? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rsandoz |
Posted: Tue Dec 05, 2006 1:16 pm Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 05, 2006 1:17 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Did it work?
Or are you not at 6.0.0.3 of the Runtime? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rsandoz |
Posted: Tue Dec 05, 2006 1:27 pm Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
No, but I have further progressed. I have something "working", but now something strikes as illogical. evaluateXPath seems to be able to "write" into the XML where createElementAsLastChild does not.
Code: |
public void evaluate(MbMessageAssembly contact admin) throws MbException {
System.out.println("Starting");
try {
MbMessage outMessage = new MbMessage(contact admin.getMessage());
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);
//works fine
outAssembly.getLocalEnvironment().getRootElement()
.evaluateXPath("/?Destination/?RouterList/?DestinationData/?LabelName[set-value('TERMINATE')]");
// should work the same as above, but rather throws com.ibm.broker.plugin.MbReadOnlyMessageException
/*outAssembly.getLocalEnvironment().getRootElement()
.createElementAsLastChild(MbElement.TYPE_NAME, "Destination", null)
.createElementAsLastChild(MbElement.TYPE_NAME, "RouterList", null)
.createElementAsLastChild(MbElement.TYPE_NAME, "DestinationData", null)
.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "labelname", "TERMINATE");*/
getOutputTerminal("out").propagate(outAssembly);
outMessage.clearMessage();
} catch (Exception e){
e.printStackTrace();
}
System.out.println("Finishing");
}
|
So in short, I have something working now, but I am feeling a little uncertainty in the solution. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 05, 2006 1:33 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Quote: |
# Make a new copy of the local environment to update it. Use the full version of the copy constructor to create a new MbMessageAssembly object, as shown in the following example:
MbMessage env = assembly.getLocalEnvironment();
MbMessage newEnv = new MbMessage(env);
newEnv.getRootElement().createElementAsFirstChild(
MbElement.TYPE_NAME_VALUE,
"Status",
"Success");
MbMessageAssembly outAssembly = new MbMessageAssembly(
assembly,
newEnv,
assembly.getGlobalEnvironment(),
assembly.getExceptionList(),
assembly.getMessage());
getOutputTerminal("out").propagate(outAssembly);
|
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rsandoz |
Posted: Tue Dec 05, 2006 1:54 pm Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
Thanks, works great. One minor issue. Eclipse was complaining deprecation. Just removed the getExceptionList parameter and all was perfect. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 05, 2006 1:57 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
|