Author |
Message
|
knaudiyal |
Posted: Mon Dec 31, 2007 2:45 am Post subject: Message Broker: Java Compute node not setting message id to |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
Hi all,
I have a scenario as follows:
JMSInput >>>> JAVAComputeNode >>>>> JMSOutput
I get a request message in the input node and i have to reply that message through the o/p node. Java, obviously is the language i am using.
I was able to create the JMS message tree as per the structure provided in the documentation.
Problem:
The message which the Java compute node is creating when appears on the queue, doesnt have the correlation id set though i am setting it in the java compute node.
Please If anybody can point out where i am wrong. I am relatively new to WMB.
Thanks and Regards
Kapil.
My code is as follows:
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
{
MbElement corrId = null;
MbElement replyTo = null;
try {
// Able to retreive values from the inmessage as per the path specified.
//<hr />
MbElement inRootElement = inMessage.getRootElement();
corrId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
replyTo = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSReplyTo");
} catch (MbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MbElement root;
try {
root = outMessage.getRootElement();
// Setting values -- which doesnt appear in the MQ queue.
//MbElement jmsTransport = root.createElementAsLastChild(MbXML.PARSER_NAME);
MbElement jmsTransport = root.createElementAsLastChild(MbXML.ELEMENT,"JMSTransport",null);
MbElement transportFolders = jmsTransport.createElementAsLastChild(MbXML.ELEMENT,"Transport_Folders",null);
MbElement headerValues = transportFolders.createElementAsLastChild(MbXML.ELEMENT,"Header_Values",null);
headerValues.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"JMSCorrelationID",corrId.getValue());
headerValues.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"JMSReplyTo",replyTo.getValue());
MbElement corridTemp = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Correction:
There is a correction in the above program. I found out, and i was told in the replies that I was using the wrong element name in creating the JMS Transport tree. Instead of using "MbXML.ELEMENT" I have to use "MbElement.TYPE_NAME". This i have confirmed by checking the type value of the JMSTransport element of the input message.
But result doesnt changes. I am still not able to see the correlation id in the message inside the queue.
Last edited by knaudiyal on Wed Jan 02, 2008 2:47 am; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Dec 31, 2007 7:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I really really really don't think you should be using MbXML in this way.
Or perhaps at all.
What suggested to you that this was the thing to do? Is there a sample somewhere?
Also, remember that in all cases you may need to set or override OutputRoot.Properties to actually set the outbound reply id. I forget, entirely, which element under OutputRoot.Properties is the same... I guess maybe it's just ReplyIdentifier? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
knaudiyal |
Posted: Mon Dec 31, 2007 9:54 am Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
Hi,
Thanks for your reply. Actually I am creating a new instance of MbMessage ( 'outMessage' in the program below)before passing it to this function. I have read in the documentation that the JMSOutput node takes the data from the JMSTransport tag before it puts the message back into the queue.
I have tried all the options. Message is being written into the queue but correlation id is not being set. I am simulating the request/reply message hence i need to set the message id into the correlation id to read back the reply.
Please let me know any other way in which i can simulate that. I feel what i am doing is also a correct approach, though there is very less documentation available for the same.
Regards
Kapil |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 01, 2008 7:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The code you posted creates the JMSTransport tree with the MbXML.ELEMENT type.
I don't think this is remotely the right thing to do. I don't know what parser should be used here, but I'm almost positive that it's not the one associated with MbXML.
You should copy JMSTransport from the input message, or do a trace and look at the constants attached to the JMSTransport tree, and use those to create a new tree yourself. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
knaudiyal |
Posted: Wed Jan 02, 2008 2:50 am Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
You were correct. The right element type to be used was "MbElement.TYPE_NAME". And i copied the input message's JMSTransport node also. But result remains the same. I cant find the correlation id set in the output message.
MbElement corrId = null;
MbElement replyTo = null;
MbElement inJMSTransport = null;
MbElement inRootElement = null;
try {
inRootElement = inMessage.getRootElement();
corrId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
replyTo = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSReplyTo");
inJMSTransport = inRootElement.getFirstElementByPath("/JMSTransport");
} catch (MbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MbElement root;
try {
root = outMessage.getRootElement();
MbElement outJMSTransport = root.createElementAsLastChild(MbElement.TYPE_NAME,"JMSTransport",null);
outJMSTransport.copyElementTree(inJMSTransport);
MbElement messageId = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
MbElement corrIdOut = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
corrIdOut.setValue(messageId.getValue());
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jan 02, 2008 5:19 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Then, again, you need to look at the Properties tree.
In v6, you need to null out the corresponding value in Properties, if you want a transport specific value to be used. Otherwise the value in Properties will override the transport specific value.
This is true for MQMD, HTTP, and I'm sure it's true for JMS as well. I think it's OutputRoot.Properties.ReplyIdentifier you need to set to null. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
knaudiyal |
Posted: Thu Jan 03, 2008 12:40 pm Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
There is one more interesting finding i have made. Message broker supports only 2 kind of JMS messages: Map and Stream. The message i was testing with was a Text message. Will post my findings after i have tried some more options out. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jan 03, 2008 12:50 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
No.
You're confused.
You can send anything you want to a JMSOutput node, you don't have to use the JMSMap or JMSStream domains. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
knaudiyal |
Posted: Fri Jan 04, 2008 1:40 am Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
I was talking about the message which i am receiving at JMSInput Node. I was sending a text message there. What I have read in the documents is that V6 support JMSMAP and JMSStream parsers only. Reply identifier array doesnt contain any values. All zeroes. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 04, 2008 5:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can receive any message domain at the JMSInput node...
JMSMap/JMSStream are just ways of structuring the data in a "java" kind of way.
I think, though, that almost nobody uses them -preferring to structure data in XML or some other delimited kind of text way.
I'm being specific when I say ReplyIdentifier needs to be set to Null. That's not at all the same as "all zeros". _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
knaudiyal |
Posted: Tue Jan 08, 2008 4:58 am Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
I have written the following code which again puts the message into the queue, but doesnt sets the correlation id. One change i see that is... previous correlation id which was being written were all 0' now the first digit is 2000000......
Do I need to do anything in JMSOutput node?. I dont see any specific setting there.
I tried many things in between, and thats the current state of the code. It really amuses me, that it is so difficult to do such a simple thing. This is a ideal example of creating a ghost out of nothing.
Eventually, all the vlaues are there but there is some header value or setting which is stopping the corr id to be published.
Code:
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
{
MbElement messageId = null;
MbElement corrId = null;
MbElement replyTo = null;
MbElement inJMSTransport = null;
MbElement inRootElement = null;
MbElement inProperties = null;
try {
inRootElement = inMessage.getRootElement();
messageId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
corrId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
replyTo = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSReplyTo");
inJMSTransport = inRootElement.getFirstElementByPath("/JMSTransport");
inProperties = inRootElement.getFirstElementByPath("Properties");
} catch (MbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MbElement root;
try {
root = outMessage.getRootElement();
root.copyElementTree(inRootElement);
MbElement replyIdentifier = root.getFirstElementByPath("/Properties/ReplyIdentifier");
MbElement outMessageId = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
MbElement corrIdOut = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
corrIdOut.detach();
corrIdOut = null;
MbElement headerValues = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values");
corrIdOut =headerValues.createElementAsLastChild(MbElement.TYPE_NAME,"JMSCorrelationID",null);
corrIdOut.setValue(outMessageId.getValue());
corrIdOut = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
replyIdentifier.detach();
replyIdentifier = null;
MbElement Properties = root.getFirstElementByPath("/Properties");
replyIdentifier = Properties.createElementAsLastChild(MbElement.TYPE_NAME,"ReplyIdentifier",null);
MbElement modified = root.getFirstElementByPath("/Properties/ReplyIdentifier");
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception ee){
ee.printStackTrace();
} |
|
Back to top |
|
 |
knaudiyal |
Posted: Sun Jan 13, 2008 9:38 pm Post subject: |
|
|
Newbie
Joined: 28 Oct 2001 Posts: 7 Location: India
|
I noticed that I was setting replyTo(out of many trial and errors). I beleive i should not set it when i am outputting a message back (aka reply). Hence have removed it from the tree.
Still no progress.
Does anyone has nay update. I know i am bothering you guys a lot.
Thanks anyways for atleast reading it.
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
{
MbElement messageId = null;
MbElement corrId = null;
MbElement replyTo = null;
MbElement inJMSTransport = null;
MbElement inRootElement = null;
MbElement inProperties = null;
try {
inRootElement = inMessage.getRootElement();
messageId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
corrId = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
replyTo = inRootElement.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSReplyTo");
inJMSTransport = inRootElement.getFirstElementByPath("/JMSTransport");
inProperties = inRootElement.getFirstElementByPath("Properties");
} catch (MbException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MbElement root;
try {
root = outMessage.getRootElement();
root.copyElementTree(inRootElement);
MbElement replyIdentifier = root.getFirstElementByPath("/Properties/ReplyIdentifier");
MbElement outReplyTo = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSReplyTo");
outReplyTo.detach();
outReplyTo = null;
MbElement outMessageId = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSMessageID");
MbElement corrIdOut = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
corrIdOut.detach();
corrIdOut = null;
MbElement headerValues = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values");
corrIdOut =headerValues.createElementAsLastChild(MbElement.TYPE_NAME,"JMSCorrelationID",null);
corrIdOut.setValue(outMessageId.getValue());
corrIdOut = root.getFirstElementByPath("/JMSTransport/Transport_Folders/Header_Values/JMSCorrelationID");
replyIdentifier.detach();
replyIdentifier = null;
MbElement Properties = root.getFirstElementByPath("/Properties");
replyIdentifier = Properties.createElementAsLastChild(MbElement.TYPE_NAME,"ReplyIdentifier",null);
MbElement modified = root.getFirstElementByPath("/Properties/ReplyIdentifier");
} catch (MbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception ee){
ee.printStackTrace();
}
} |
|
Back to top |
|
 |
|