Author |
Message
|
niraj.chaudhary |
Posted: Tue Apr 22, 2008 5:56 am Post subject: MQmessage.writeUTF vs MQmessage.writeString |
|
|
Novice
Joined: 20 Jun 2007 Posts: 22 Location: UK
|
Hi,
My MDB is not able to read the messages which are being sent using either MQmessage.writeUTF or MQmessage.writeString. My MDB tries to typecast the incoming messages as Text message?
Can any one suggest me, which MQ JMS api should be used here?
thanks,
Niraj |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 22, 2008 6:05 am Post subject: Re: MQmessage.writeUTF vs MQmessage.writeString |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
niraj.chaudhary wrote: |
Can any one suggest me, which MQ JMS api should be used here?
|
The one which matches the coding (as converted if converted) of the message? Which will be text messages in both of the examples you give?
What exactly is the problem you're getting, because that answer is fairly easy to deduce? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Apr 22, 2008 7:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Neither using writeString or writeUTF will change the format of the message.
But do not use writeUTF. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
niraj.chaudhary |
Posted: Tue Apr 22, 2008 9:47 pm Post subject: |
|
|
Novice
Joined: 20 Jun 2007 Posts: 22 Location: UK
|
The problem is I tried using both writeString and writeUTF, but in both the case MDB has thrown an exception when trying to create a text message out of incoming message.
Both the sender (implementing MQ JMS) and receiver (an MDB) are using the same queue manager.
Why MDB is not able to create a text message out of incoming message is my problem?
thanks... |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 23, 2008 12:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
niraj.chaudhary wrote: |
in both the case MDB has thrown an exception when trying to create a text message out of incoming message. |
If we knew what the exception was, we might be able to offer an opinion.
I'm also slightly confused - you say that the write functions throw as exception creating a text message out of an incoming message. What incoming message? What's reading that? Do you mean the read fails or the write? Or the read of the message written by either writeString or writeUTF?
More details please. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Apr 23, 2008 1:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You need to set the FORMAT of the message.
This is not done with writeString, nor with writeUTF. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 23, 2008 2:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
niraj.chaudhary wrote: |
The problem is I tried using both writeString and writeUTF, but in both the case MDB has thrown an exception when trying to create a text message out of incoming message.
Both the sender (implementing MQ JMS) and receiver (an MDB) are using the same queue manager.
Why MDB is not able to create a text message out of incoming message is my problem?
thanks... |
In order for the incoming message to be cast successfully into a TextMessage you need for that message to have a format of MQFMT_STRING.
So your producer/sender is not sending a TextMessage and you are astounded that you can't (magically) cast it to a TextMessage??
Anything else will fail.
And what is going on in your environment? From your post I can guess that your are sending a BytesMessage... So how do you expect to cast it to a TextMessage??
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
niraj.chaudhary |
Posted: Wed Apr 23, 2008 11:10 pm Post subject: |
|
|
Novice
Joined: 20 Jun 2007 Posts: 22 Location: UK
|
The following code takes care of sending a text message:
MQMessage.format = MQC.MQFMT_STRING;
I was not aware of the fact that the default format will send bytemessages
thanks for all the help! |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Apr 24, 2008 8:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
niraj.chaudhary wrote: |
The following code takes care of sending a text message:
MQMessage.format = MQC.MQFMT_STRING;
I was not aware of the fact that the default format will send bytemessages
thanks for all the help! |
Only in Base. If you have a JMS sender you create a TextMessage and you will be good.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|