Posted: Wed Feb 02, 2005 6:53 pm Post subject: Can not get the value from readString outside the method
Newbie
Joined: 02 Feb 2005 Posts: 2
The problem im having is that outside of the method that I get the message off the queue I can not get the string with readString. It will correctly give me the length but when i try to do a readstring(length) it throws the IOException error. Here is a sample of the code below. The queues are clustered
THIS IS THE METHOD CALL
public void call()
{
MQMessage msg = getOutQueue();
int temp = msg.getTotalMessageLength();
try
{
//this will not print the message and throws IOException
System.out.println("MSG ="+msg.readString(temp));
return theMessage;
}
catch(IOException e)
{}
}
THE ACTUAL METHOD and returns type MQMESSAGE
public MQMessage getOutQueue()
{
MQMessage theMessage = new MQMessage();
getSeqMO.options = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_SYNCPOINT | MQC.MQGMO_WAIT;
getSeqMO.matchOptions = MQC.MQMO_MATCH_CORREL_ID;
theMessage.encoding = MQC.MQENC_NATIVE;
theMessage.characterSet = MQC.MQCCSI_Q_MGR;
theMessage.correlationId = seqNum.getBytes();
theMessage.messageId = seqNum.getBytes();
getSeqMO.waitInterval = getTime;
queue.get(theMessage, getSeqMO);
int length = theMessage.getTotalMessageLength();
String temp = theMessage.readString(length);
System.out.println(temp)//this will print correctly
return theMessage;
}
To answer my question with the read call, the pointer has moved to the end and then calling the read again its reading beyond the buffer and the IOException is thrown with end of file. The pointer has to be reset to the beginning of the MQMessage
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