Author |
Message
|
buckrodgers |
Posted: Wed Feb 03, 2010 1:05 pm Post subject: I'm sending an ObjectMessage but receiving a JMSBytesMessage |
|
|
Newbie
Joined: 03 Feb 2010 Posts: 2
|
I'm sending an ObjectMessage to a local queue, however my MDB is reading a JMSBytesMessage. Isn't there a way to get this message as an ObjectMessage ?
I'm using WAS 7 and MQ 6 |
|
Back to top |
|
 |
Vitor |
Posted: Wed Feb 03, 2010 1:16 pm Post subject: Re: I'm sending an ObjectMessage but receiving a JMSBytesMes |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
buckrodgers wrote: |
Isn't there a way to get this message as an ObjectMessage ? |
a) My Java sucks so I'm not entirely certain (!)
b) No I don't think there is
c) My understanding is that it's considered best practice to serialise / deserialize Java objects for transmission anyway
Someone who doesn't suffer from a) above will be along shortly, and they may correct either b) or c) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 03, 2010 1:20 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You can cast it to an ObjectMessage, of course.
But how do you know you have the necessary versions of the classes that were used to build the ObjectMessage in the first place?
What happens if you need to send the same information to a consumer that is not written in Java?
ObjectMessages are extremely unportable. |
|
Back to top |
|
 |
buckrodgers |
Posted: Wed Feb 03, 2010 4:16 pm Post subject: |
|
|
Newbie
Joined: 03 Feb 2010 Posts: 2
|
Thanks for the reply.
The app that is the producer is also the consumer so everything should be the same when getting the message back and processing it. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Feb 03, 2010 4:35 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
buckrodgers wrote: |
The app that is the producer is also the consumer so everything should be the same when getting the message back and processing it. |
We all hope this happy fact remains true for the life of this design.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
manicminer |
Posted: Thu Feb 04, 2010 1:05 am Post subject: Re: I'm sending an ObjectMessage but receiving a JMSBytesMes |
|
|
 Disciple
Joined: 11 Jul 2007 Posts: 177
|
Vitor wrote: |
buckrodgers wrote: |
Isn't there a way to get this message as an ObjectMessage ? |
a) My Java sucks so I'm not entirely certain (!)
b) No I don't think there is
c) My understanding is that it's considered best practice to serialise / deserialize Java objects for transmission anyway
Someone who doesn't suffer from a) above will be along shortly, and they may correct either b) or c) |
I agree with c)
Don't use object messages, transform your data into some intermediate format (xml is popular) and use that. This provides much better interoperability as apps other than java can read the data (e.g. message broker could do content based routing on your xml if required) and avoids all the contact admin Java serialisation pitfalls that will almost certainly bite you at some point in the applications lifetime!
Side note: In theory serialised objects should be fine, but one day someone will add a field to your object without considering the serialisation impact. Or will create a new object and forget to specify the serial UID. Or will add a field that is not serialisable etc. _________________ Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 04, 2010 5:31 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
buckrodgers wrote: |
Thanks for the reply.
The app that is the producer is also the consumer so everything should be the same when getting the message back and processing it. |
Yes, that's certainly true today.
Tomorrow, when someone else needs a copy of the message, or when for performance reasons the producer component gets moved to a separate machine from the consumer component, and then gets upgraded separately... |
|
Back to top |
|
 |
|