Author |
Message
|
fredand44 |
Posted: Wed Mar 12, 2008 7:44 am Post subject: How do I set RFH2 header values? |
|
|
Acolyte
Joined: 14 Feb 2006 Posts: 63
|
Hello!
I got a application in Java that receives a JMSMessage of type TextMessage.
This message got 2 properties.
String prop1 = textMessage.getStringProperty("prop1");
String prop2 = textMessage.getStringProperty("prop2");
Now I need to create a MQMessage (com.ibm.mq.MQMessage)
MQMessage mqMessage = new MQMessage ();
This mqMessage will be posted to a MQBroker later on.
In the mqMessage I need to set the prop1 and prop2 in the RFH2 header but I can not find any way how to set it?
The properties is needed for routing in the MQBroker.
I would love some input regarding this problem.
Best regards
Fredrik |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 12, 2008 3:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to program in JMS and not java base. The method setProperty("name", value) is to be used.
If you are not in a java env try XMS or RFHUtil (IH03)
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fredand44 |
Posted: Thu Mar 13, 2008 12:07 am Post subject: Not as I expected! |
|
|
Acolyte
Joined: 14 Feb 2006 Posts: 63
|
Hello!
That does not sound good at all!
(Everything is in Java)
The thing is that "textMessage" is one object of Java class: weblogic.jms.common.TextMessageImpl
The "mqMessage" is an other object of Java class:
com.ibm.mq.MQMessage
What I need to do is to:
String text = textMessage.getText();
String prop1 = textMessage.getStringProperty("prop1");
String prop2 = textMessage.getStringProperty("prop2");
Then I need to create the new object:
MQMessage mqMessage = new MQMessage ();
mqMessage.writeString(text);
I also need to add the routing params to the new object, "mqMessage".
I guess then it is impossible to configure the object "mqMessage" with setProperty?? Or is there anyway?
Later I send the mqMessage to a queue like:
MQQueueManager mqQueueManager = new MQQueueManager("MyMQQueueManager");
MQQueue mqQueue = mqQueueManager.accessQueue("MyMQQueue", MQC.MQOO_OUTPUT);
mqQueue.put(mqMessage);
I really need to add the properties to be able to route the message "mqMessage".
Hope you see the problem.
Perhaps there is an better approach??
Else I guess I'm doomed!!!
/Fredrik |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 13, 2008 1:08 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
WHY do you need to switch from using JMS to using non-JMS?
You can create a new TextMessage, and set your properties there, and send that.
Otherwise, you can use an MQMessage, but then you have to build an MQRFH2 header on that message to hold all of the JMS properties. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fredand44 |
Posted: Thu Mar 13, 2008 1:45 am Post subject: I guess it is to complex... |
|
|
Acolyte
Joined: 14 Feb 2006 Posts: 63
|
Hello!
Thanks for your response!
I guess you are right it looks to complex to build the entire message with MQRH2 header.
But is it possible with JMS to set the following values in a TextMessage or perhaps a BytesMessage?
mqMessage.format
mqMessage.characterSet
mqMessage.encoding
Best regards
Fredrik |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 13, 2008 7:00 pm Post subject: Re: I guess it is to complex... |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
fredand44 wrote: |
Hello!
Thanks for your response!
I guess you are right it looks to complex to build the entire message with MQRH2 header.
But is it possible with JMS to set the following values in a TextMessage or perhaps a BytesMessage?
mqMessage.format
mqMessage.characterSet
mqMessage.encoding
Best regards
Fredrik |
Check out he using java manual. It'll show you how the JMS and base properties match.
- Setting the format. You don't do that. It gets set by the specific message class you create (TextMessage vs BytesMessage etc...)
- Character set can be set through JNDI/URI options. However the best method is to set the ccsid on your connection factory. Just make sure the data you pass to MQ is in the ccsid you declared your CF to be in.
For this you could use multiple CF / connection/ session instances each with a different CCSID...
- Encoding -- read up on the manual. We usually don't set it and let the qmgr set it to the one of its platform
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|