|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQMessage.ReadString Unable to read beyond the end of stream |
« View previous topic :: View next topic » |
Author |
Message
|
ryanframes |
Posted: Sun Mar 07, 2021 8:10 pm Post subject: MQMessage.ReadString Unable to read beyond the end of stream |
|
|
Newbie
Joined: 07 Mar 2021 Posts: 1
|
Hello,
I have a c# program that read MQ Message, it works for almost 7 months. But now suddenly it throw error
"Unable to read beyond the end of the stream at System.IO.BinaryReader.ReadString() at IBM.WMQ.MQMessage.ReadString(Int32 length) at ....."
Here's my code snippet to read MQ Message
Code: |
if (CountMessage(p_sQueue) > 0)
{
oMQQueue = m_oMQQueueManager.AccessQueue(p_sQueue, IBM.WMQ.MQC.MQOO_INPUT_EXCLUSIVE | IBM.WMQ.MQC.MQOO_FAIL_IF_QUIESCING);
if (oMQQueue == null)
{
m_sErrorMessage = "Get : MQQueue is null";
return false;
}
MQMessage oMQMessage = new MQMessage();
MQGetMessageOptions oMQGetMessageOptions = new MQGetMessageOptions();
oMQGetMessageOptions.Options = IBM.WMQ.MQC.MQGMO_WAIT;
oMQGetMessageOptions.WaitInterval = m_iTimeout * 1000;
oMQGetMessageOptions.MatchOptions = IBM.WMQ.MQC.MQMO_NONE;
oMQQueue.Get(oMQMessage, oMQGetMessageOptions);
//string strRqId = oMQMessage.GetStringProperty("usr_UUID");
//byte[] bty = null;
//oMQMessage.ReadFully(ref bty);
//p_sMessage = System.Text.Encoding.UTF8.GetString(bty);
p_sMessage = oMQMessage.ReadString(oMQMessage.MessageLength);
oMQMessage.ClearMessage();
oMQMessage = null;
oMQGetMessageOptions = null;
return true;
}
|
I'm using version 8.0.0.7
What could be possibly the cause for it to happen ?
found some link that useful :
en*morzel*net/post/IBMWMQMQMessageReadString-and-EndOfStreamException
Quote: |
The error was reported, because sometimes in two different locations there was a call to ReadString method on the same MQMessage object: |
but i never call this method more than one time, and i create MQMessage as Local Variable !
Now , i want to replicate this bug in development environment but i dont know what to do ?
Any help / advice regarding this error will be appreciated.
Thank you. |
|
Back to top |
|
 |
hughson |
Posted: Sun Mar 07, 2021 10:04 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
What is the value of oMQMessage.MessageLength when you get this error? Does this not simply imply that it is zero?
Where is the code to check whether you were actually returned a message on the oMQQueue.Get call.
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
bruce2359 |
Posted: Sun Mar 07, 2021 10:06 pm Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
So, it worked for 7 months and now it gets an error.
What has changed? Program Code? O/S? MQ?
If you say that nothing has changed, it is unlikely that we will believe you.
How is the data (in error) different from when the app worked? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
tczielke |
Posted: Mon Mar 08, 2021 5:43 am Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
This issue reminds me of the scenario where the readString method hits an error because the number of chars and number of bytes do not coincide. In Java, we use code like this to account for this type of scenario.
Code: |
queue.get(rcvMessage, gmo);
int length = rcvMessage.getDataLength();
String msgText = rcvMessage.readStringOfByteLength(length);
|
Here is a blurb from the readString method for the MQMessage class:
Quote: |
Parameters:
length - The number of characters to read (which might differ from the number of bytes according to the codeset, since some codesets use more than one byte per character).
|
_________________ Working with MQ since 2010. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 08, 2021 6:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why are you trying to read a string when you haven't ascertained the format of the message to be a MQFMT_STRING?
You could have a binary content that includes a string terminator... Hence your error message?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|