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 » Question about MQMessage.readString()

Post new topic  Reply to topic
 Question about MQMessage.readString() « View previous topic :: View next topic » 
Author Message
pjramana
PostPosted: Mon Mar 22, 2004 12:29 pm    Post subject: Question about MQMessage.readString() Reply with quote

Novice

Joined: 08 Mar 2004
Posts: 14

I am trying to print the message that i set in MQMessage object. And i am getting java.io.EOFException.

The code snipped looks like this.

String message = "SOME String that is 700+ chars in length";
sentMessage.writeString( message );
sentMessage.expiry = this.msgExpiryInterval;
sentMessage.replyToQueueName = this.replyToQueue;
.sentMessage.messageType = MQC.MQMT_REQUEST;

MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_NEW_CORREL_ID ;

System.out.println("Writing Message to Queue:"+ this.sentMessage.getMessageLength() +" ["+message.length());
[color=red]System.out.println("Writing Message to Queue:"+ this.sentMessage.readString(this.sentMessage.getMessageLength()));
[/color]
------------------------------------------------------------------------------
Exception details.

java.io.EOFException
at com.ibm.mq.MQMessage.readConvertedString(MQMessage.java:1943)
at com.ibm.mq.MQMessage.readString(MQMessage.java:960)

------------------------------------------------------------------------
Is there anything special i need to do to read the message from MQMessage. I am using "i18n.jar" in classpath.

Thanks,
Janaki.
Back to top
View user's profile Send private message
pjramana
PostPosted: Mon Mar 22, 2004 12:31 pm    Post subject: Reply with quote

Novice

Joined: 08 Mar 2004
Posts: 14

This is the line that is giving the problem.

System.out.println("Writing Message to Queue:"+ this.sentMessage.readString(this.sentMessage.getMessageLength())); //Last line in the code snippet.
Back to top
View user's profile Send private message
vennela
PostPosted: Mon Mar 22, 2004 12:38 pm    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Try something like this

Code:

getOptions.options = MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT;
_inQ.get(getMsg, getOptions);
byte[] b = new byte[getMsg.getMessageLength()];
getMsg.readFully(b);
replyMsg = new String(b);


I copied the code from some other post. You may try searching the forum for readFully
Back to top
View user's profile Send private message Send e-mail Visit poster's website
clindsey
PostPosted: Mon Mar 22, 2004 12:43 pm    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

Try this.sentMessage.seek(0) to return back to the start of the stream before you do the readString.

Charlie
Back to top
View user's profile Send private message
pjramana
PostPosted: Mon Mar 22, 2004 12:57 pm    Post subject: Reply with quote

Novice

Joined: 08 Mar 2004
Posts: 14

this.sentMessage.seek(0) worked perfect.

was i getting that EOFException because of the message read pointer pointing at the end of the message?

I am curious to know the way that MQMessage works. If someone can post that info, that would be great.

Thanks charlie.


Janaki.
Back to top
View user's profile Send private message
clindsey
PostPosted: Mon Mar 22, 2004 6:01 pm    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

Quote:

was i getting that EOFException because of the message read pointer pointing at the end of the message

yes, exactly

Quote:

I am curious to know the way that MQMessage works. If someone can post that info, that would be great

Janaki, I would say there are 2 pieces; one is the attributes of the message, like priority, expiry, format, etc. The second is the message buffer which is a java byte stream. The MQMessage class implements DataInput and DataOutput which includes many methods like readInt, writeLong, readFully, etc..... and throws all the exceptions of these implementations such as IOException and EOFException.

If you have already looked at the MQMessage documentation, go to the WebSphere MQ Using Java manual and you can see all the attributes and methods.

Charlie
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 » Question about MQMessage.readString()
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.