Author |
Message
|
anild |
Posted: Tue Apr 28, 2009 5:25 am Post subject: Propagate messages in Javacompute Node |
|
|
Novice
Joined: 19 Sep 2007 Posts: 13
|
Hi,
I am trying to propagate messages with in java compute node using for loop as
public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbMessage inMessage = contact admin.getMessage();
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);
copyMessageHeaders(inMessage, outMessage);
try {
for (int i = 0; i < 3; i++) {
MbElement xmlnsc = outMessage.getRootElement().createElementAsLastChild("XMLNSC");
xmlnsc.createElementAsLastChild(MbXMLNSC.FOLDER, "Sample" + i, null);
getOutputTerminal("out").propagate(outAssembly);
outMessage.clearMessage();
}
} catch (Exception e) {
e.printStackTrace();
}
}
But each time it is propagating only 1 message instead of 3. It is not giving me any errors but I think that the control is not returned to Java Compute Node once the propagate function is called.
So, I wanted to check if we can use propagate statement with in loop constructs in Java Compute Node. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 28, 2009 5:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
There's nothing obviously wrong with your loop. So if it is failing to loop, and you haven't actually demonstrated that (perhaps you should take a usertrace), then it is caused by something other than your use of propagate.
The rest of the code, however, probably doesn't do what you think it does. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Apr 28, 2009 5:54 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
do you need to reinitialise the out message inside the loop as its been cleared when the loop enters the 2nd and 3rd iterations.
Just a thought  |
|
Back to top |
|
 |
anild |
Posted: Tue Apr 28, 2009 5:59 am Post subject: |
|
|
Novice
Joined: 19 Sep 2007 Posts: 13
|
Hi,
I think that it might not be the issue. As long as you don't assign the outMessage to null it will not require reinitializing.
WMBDEV1 wrote: |
do you need to reinitialise the out message inside the loop as its been cleared when the loop enters the 2nd and 3rd iterations.
Just a thought  |
|
|
Back to top |
|
 |
sknrt1 |
Posted: Tue Apr 28, 2009 7:18 am Post subject: |
|
|
Apprentice
Joined: 22 Jan 2003 Posts: 39 Location: USA
|
Hi anild,
You have to re-initialize outMessage, (as suggested by WMBDEV1), default behaviour of propagation is to clear outmessage (outputroot), which you can override by using DEFAULT NONE flag of the PROPAGATE statement (explore how to set the same in java compute node). So, try to move the initialization code into the loop and you can see the result.
Thanks _________________ ------------------------------------------
sk
MQ User since 2001
Message Broker User since 2001
IBM Certified
Solution Designer - WebSphere MQ
Solution Developer - Message Broker |
|
Back to top |
|
 |
anild |
Posted: Mon May 04, 2009 3:05 am Post subject: |
|
|
Novice
Joined: 19 Sep 2007 Posts: 13
|
Hi,
We have tried the same. But as mentioned earlier, the problem was not due to intialization but due to the control not returning to JavaCompute node after calling propagate on out terminal. Hence the initialization code has no effect what so ever as it is not getting invoked the second time.
sknrt1 wrote: |
Hi anild,
You have to re-initialize outMessage, (as suggested by WMBDEV1), default behaviour of propagation is to clear outmessage (outputroot), which you can override by using DEFAULT NONE flag of the PROPAGATE statement (explore how to set the same in java compute node). So, try to move the initialization code into the loop and you can see the result.
Thanks |
|
|
Back to top |
|
 |
joebuckeye |
Posted: Mon May 04, 2009 6:05 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Where does the message go next in the flow? You have propagated the message so maybe it is locking up somewhere further down the flow.
I seem to remember once when we were looking at something dealing with propagating a message numerous times that the thread running the JCN processes the propagated message to it's endpoint before coming back to the loop. |
|
Back to top |
|
 |
|