Author |
Message
|
anilmekala |
Posted: Mon Jun 01, 2015 10:04 pm Post subject: Regarding JCN |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi,
I hope everybody doing good.
I have small scenario by using JCN.
my flow looks as below
MQINPUT -->JCN --> MQOUTPUT
I had given message message domain As XMLNSC for MQINPUT node.
When i debug my flow am able to Message tree properly
When trying access the payload element am getting Runtime exception.
Please let me know do i need to do any configurations in IIB JCN.
Please find my JCN code as below :
Code: |
MbOutputTerminal out = getOutputTerminal("out");
MbMessage message = assembly.getMessage();
MbMessage newMsg= new MbMessage(message);
try {
// optionally copy message headers
copyMessageHeaders(message, newMsg);
// ----------------------------------------------------------
// Add user code below
MbElement root = newMsg.getRootElement();
MbElement body = root.getLastChild();
String bodymessage = body.getValue().toString();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
newMsg);
out.propagate(outAssembly);
// End of user code
// ----------------------------------------------------------
} catch (MbException e) {
// Re-throw to allow Broker handling of MbException
throw e;
} catch (RuntimeException e) {
// Re-throw to allow Broker handling of RuntimeException
e.printStackTrace();
} catch (Exception e) {
// Consider replacing Exception with type(s) thrown by user code
// Example handling ensures all exceptions are re-thrown to be handled in the flow
throw new MbUserException(this, "evaluate()", "", "", e.toString(),
null);
}
// The following should only be changed
// if not propagating message to the 'out' terminal
}
|
Thanks in Advance for your help.
Regards,
Anil. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jun 02, 2015 2:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Well you have a new message, so you copy the headers...
What you access as Body is in fact the last child of OutputRoot.... which at that point points to the last header.
You need to declare a parser and then copy a body... Look at the samples with JCN. This will help you build your code...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
inMo |
Posted: Tue Jun 02, 2015 6:07 am Post subject: |
|
|
 Master
Joined: 27 Jun 2009 Posts: 216 Location: NY
|
You don't mention the exception anywhere. Are you able to observe & communicate the error condition? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 02, 2015 6:15 am Post subject: Re: Regarding JCN |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
anilmekala wrote: |
Code: |
String bodymessage = body.getValue().toString(); |
|
That's entirely nonsense and doesn't do anything useful. |
|
Back to top |
|
 |
iibmate |
Posted: Tue Jun 02, 2015 7:51 pm Post subject: Re: Regarding JCN |
|
|
 Apprentice
Joined: 17 Mar 2015 Posts: 38 Location: Perth, WA
|
mqjeff wrote: |
anilmekala wrote: |
Code: |
String bodymessage = body.getValue().toString(); |
|
That's entirely nonsense and doesn't do anything useful. |
Correct.
Should use
bodymessage = body.getlastchild().getValue().toString(); if xml message is having only one root tag with value.
Posting queries without correct info does nt make sence. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jun 03, 2015 5:10 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The XML document will have been turned into a complete message tree.
You do not need to parse it again.
You just have to understand how to write Broker code in a JCN. |
|
Back to top |
|
 |
anilmekala |
Posted: Thu Jun 04, 2015 12:22 am Post subject: |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi,
Thank you so much for your response.
my issue got resolved . I forgot add message domain to outputroot element.
Regards,
Anil. |
|
Back to top |
|
 |
|