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 » MQmessage.writeUTF vs MQmessage.writeString

Post new topic  Reply to topic
 MQmessage.writeUTF vs MQmessage.writeString « View previous topic :: View next topic » 
Author Message
niraj.chaudhary
PostPosted: Tue Apr 22, 2008 5:56 am    Post subject: MQmessage.writeUTF vs MQmessage.writeString Reply with quote

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
View user's profile Send private message Yahoo Messenger
Vitor
PostPosted: Tue Apr 22, 2008 6:05 am    Post subject: Re: MQmessage.writeUTF vs MQmessage.writeString Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Apr 22, 2008 7:20 am    Post subject: Reply with quote

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
View user's profile Send private message
niraj.chaudhary
PostPosted: Tue Apr 22, 2008 9:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger
Vitor
PostPosted: Wed Apr 23, 2008 12:33 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 23, 2008 1:49 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Apr 23, 2008 2:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
niraj.chaudhary
PostPosted: Wed Apr 23, 2008 11:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger
fjb_saper
PostPosted: Thu Apr 24, 2008 8:44 am    Post subject: Reply with quote

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
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 » MQmessage.writeUTF vs MQmessage.writeString
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.