Author |
Message
|
dotaneli |
Posted: Tue Jul 07, 2009 1:13 am Post subject: User defined properties to be mapped from JMS to MQ |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
Hello everyone.
One of my clients has an application that needs to run both with JMS and MQ Base api. All Java.
He has a need for application defined fields, which are easy to set using JMS:
jmsMsg.setStringProperty("StringPropertyName", "PropertyValue");
When I write a message with these properties, and after that i read it, i can print these values. All is well when using JMS.
However, if I want to see these values on an MQ message, where should I look? Is it in the RFH header? Is it in the body? Can rfhutil see it?
How do I set or get these properties using only MQ Base api? We tried using com.ibm.mq.headers, but this jar does not exist, nor is it traceable through the web.
Any ideas?
Thanks. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 07, 2009 1:24 am Post subject: Re: User defined properties to be mapped from JMS to MQ |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dotaneli wrote: |
where should I look? Is it in the RFH header? Is it in the body? Can rfhutil see it? |
In the usr folder of the RFH. As the name suggests, rfhutil is intended to view messages with this header.
dotaneli wrote: |
How do I set or get these properties using only MQ Base api? |
You'll need to hand craft code to manipulate the RFH. In base MQ terms, it's part of the message. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Jul 07, 2009 1:41 am Post subject: Re: User defined properties to be mapped from JMS to MQ |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Vitor wrote: |
You'll need to hand craft code to manipulate the RFH. |
Theres examples on this forum if you look for them.... |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 1:52 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
10x alot...
But again - i can't see why these fields are not available to me.
This is the relevant code:
jmsMsg = qSession.createBytesMessage();
((BytesMessage)jmsMsg).writeBytes("String message".getBytes());
jmsMsg.setStringProperty("TestProp2", "value of 2");
jmsMsg.setIntProperty("IntPropertyName", 2);
//jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2);
qSender.send(jmsMsg);
jmsMsg = null;
jmsMsg = qReceiver.receiveNoWait();
Enumeration props = jmsMsg.getPropertyNames();
System.out.println("\nTest #2 - Byte message properties, no specific queue parameters");
while (props.hasMoreElements()) {
String element = (String)props.nextElement();
System.out.println(element + " = " +jmsMsg.getStringProperty(element));
}
As you can see, the code puts and gets a message.
If I try to get the message using rfhutil, the <usr> sections remains empty.
Why is that? |
|
Back to top |
|
 |
anilit99 |
Posted: Tue Jul 07, 2009 2:08 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Jul 07, 2009 2:15 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
What happens if you set the properties before you write the message body?
What does the message look like on the queue when viewed through RFHUTIL (ie is this an issue with your putting code which might be fixed by doing as recommended above or is it an issue with the getting code?) |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 2:20 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
thanks,
but when i set
jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2);
The result is:
javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1827)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1139)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1215)
at MQTesJMStPropertiesMain.main(MQTesJMStPropertiesMain.java:56)
...
Any other ideas..? |
|
Back to top |
|
 |
anilit99 |
Posted: Tue Jul 07, 2009 2:22 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
I am sure some body is gonna say - "post the linked exception" !! _________________ "I almost care !" |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 2:23 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
WMBDEV1:
The problem seems to be with the putting code..
Since the program both write and reads, and after reading is is capable of printing the user defined fields, it seems that the JMS-to-MQ conversion is defected, because i did something wrong when writing the message.
As i said, I added:
jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2);
The result is mentioned above.. |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 2:30 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
Which more detailed excpetions are needed?
Are the any other exceptions other than the Java stack? |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Jul 07, 2009 2:32 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
dotaneli wrote: |
As i said, I added:
jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2);
The result is mentioned above.. |
That wasnt what I asked, please reread my post and makes the changes I requested in my first line. |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 2:42 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
Well, I did that, just forgot to mention it.
Here is the new piece of code:
jmsMsg = null;
jmsMsg=qSession.createTextMessage();
jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2);
jmsMsg.setStringProperty("StringPropertyName", "PropertyValue");
jmsMsg.setIntProperty("IntPropertyName", 1);
((TextMessage)jmsMsg).setText("String message");
qSender.send(jmsMsg);
Still, same exception:
javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:622)
at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1827)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1139)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1215)
at MQTesJMStPropertiesMain.main(MQTesJMStPropertiesMain.java:56) |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 07, 2009 2:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dotaneli wrote: |
Still, same exception:
javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
|
You need to extract the linked exception with the WMQ reason code. There are examples in the forum. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Tue Jul 07, 2009 2:47 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
dont set
jmsMsg.setStringProperty("JMS_IBM_Format", MQC.MQFMT_RF_HEADER_2); |
|
Back to top |
|
 |
dotaneli |
Posted: Tue Jul 07, 2009 2:58 am Post subject: |
|
|
Voyager
Joined: 19 Oct 2005 Posts: 99 Location: Israel
|
WMBDEV1:
Well - when i DON'T set it, i cannot see the relevant custom fields in the rfhutil...
And - can someone direct me to a post that explains how to extract the linked MQ error code?
10x. |
|
Back to top |
|
 |
|