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 » Writing MQ message as ObjectMessage( for JMS Client)

Post new topic  Reply to topic
 Writing MQ message as ObjectMessage( for JMS Client) « View previous topic :: View next topic » 
Author Message
nanotech
PostPosted: Fri May 29, 2009 11:25 am    Post subject: Writing MQ message as ObjectMessage( for JMS Client) Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

Hi,
I have a JMS app which writes ObjectMessage to a queue. This message contains HashMap object.

HashMap myMap = new HashMap();
myMap.put("TEST","123");

ObjectMessage objMsg = session.createObjectMessage();
objectMsg.setObject(myMap);


Message is read on the other side by a non-JMS MQ Client and after some processing is put back on the other queue as HashMap object, to which JMS client is listening .

When JMS application receives message it is coming back as BytesMessage, BUT we really want that message to be ObjectMessage so that it can be processed easily.

Can someone please suggest me where to start looking in order to achieve this.

Thanks,
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri May 29, 2009 12:18 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Start by doing anything other than writing object messages.
Write a text message with a set of properties (name=value) that you can parse using standard Java property APIs, or XML, or anything other than something as language and potentially JVM specific thing as an ObjectMessage.

Really. Please don't do that.
Back to top
View user's profile Send private message
nanotech
PostPosted: Fri May 29, 2009 12:45 pm    Post subject: Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

Hi Thanks for replyiing, There is a reason for doing that. Well, while incoming message to MQ Client can be a text message but when MQClient writes its back it has to be some object(either a POJO or HashMap) because it contains bytes[] for the file that i want to send back plus other meta-information.

mqjeff wrote:
Start by doing anything other than writing object messages.
Write a text message with a set of properties (name=value) that you can parse using standard Java property APIs, or XML, or anything other than something as language and potentially JVM specific thing as an ObjectMessage.

Really. Please don't do that.


Is there any better way of doing. Or, is there a setting that I can do somewhere in headers so that JMS Client does not treat incoming message from MQClient (which can be a POJO or HashMap) as BytesMessage but treat it as ObjectMessage.

Thanks,
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri May 29, 2009 1:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

nanotech wrote:

Is there any better way of doing. Or, is there a setting that I can do somewhere in headers so that JMS Client does not treat incoming message from MQClient (which can be a POJO or HashMap) as BytesMessage but treat it as ObjectMessage.

Thanks,


First I'd like to emphasize mqjeff's comment, and point you to best practice, to really not do that...

Now if you absolutely have to you could try using a ObjectInputStream built of a ByteArrayInputStream built off the message.getBytes[]

At your own risk.

I still believe it would be better to exchange this as a list of property/value pairs...in xml.



Have fun
_________________
MQ & Broker admin


Last edited by fjb_saper on Fri May 29, 2009 1:15 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri May 29, 2009 1:12 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

nanotech wrote:
it contains bytes[] for the file that i want to send back plus other meta-information.

XML with a base64 encoded segment.

Or a MIME document.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Writing MQ message as ObjectMessage( for JMS Client)
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.