ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » How do I set RFH2 header values?

Post new topic  Reply to topic
 How do I set RFH2 header values? « View previous topic :: View next topic » 
Author Message
fredand44
PostPosted: Wed Mar 12, 2008 7:44 am    Post subject: How do I set RFH2 header values? Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 12, 2008 3:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
fredand44
PostPosted: Thu Mar 13, 2008 12:07 am    Post subject: Not as I expected! Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 13, 2008 1:08 am    Post subject: Reply with quote

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
View user's profile Send private message
fredand44
PostPosted: Thu Mar 13, 2008 1:45 am    Post subject: I guess it is to complex... Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 13, 2008 7:00 pm    Post subject: Re: I guess it is to complex... Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How do I set RFH2 header values?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.