Author |
Message
|
frankzwo |
Posted: Thu Sep 07, 2006 9:20 pm Post subject: call readFully again and other readFully Problems |
|
|
Newbie
Joined: 22 Dec 2005 Posts: 6
|
Hi,
i would like to call readFully twice but it is not possible.
I get an EOFException, can i read the Message again, after i have call the readFully method.
Thanks.
Frank
Last edited by frankzwo on Thu Sep 07, 2006 11:57 pm; edited 1 time in total |
|
Back to top |
|
 |
deepu4u |
Posted: Thu Sep 07, 2006 10:20 pm Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
You can not do it again coz buffer has a offset which icsset to the end of buffer once you have done readFully(byte b[]).
To see how it works please use getDataOffset() method before readFully and after readFully(). After reafFully() it reached the end of message thats why you got EOFException. |
|
Back to top |
|
 |
deepu4u |
Posted: Thu Sep 07, 2006 10:22 pm Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
Anyways if you want to use readFully again then after first readFully() use Message.setDataOffset(0). |
|
Back to top |
|
 |
frankzwo |
Posted: Thu Sep 07, 2006 11:55 pm Post subject: |
|
|
Newbie
Joined: 22 Dec 2005 Posts: 6
|
thanks
i would like to extract a part of the message, i have successfully readout the rf2header, but i have problem to read out the body of the message
if i access the body with
Code: |
bodylength = this.m_messageSize-this.m_msgBodyOffset;
this.m_messageBodyByt = new byte[bodylength];
mqMsg.readFully(this.m_messageBodyByt, this.m_msgBodyOffset, bodylength);
|
i get an
java.lang.IndexOutOfBoundsException
at java.io.ByteArrayInputStream.read(ByteArrayInputStream.java:160)
at java.io.DataInputStream.readFully(DataInputStream.java:266)
at com.ibm.mq.MQMessage.readFully(MQMessage.java:549)
Exception, if the m_msgBodyOffset is > 0
bodylength is the length of the whole body part of the message
m_messageBodyByt is the buffer, which i would like to save this part
m_msgBodyOffset is the position, i would like to begin to read
thank you very much for your help
Frank |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Sep 08, 2006 2:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Looks to me like you might be skipping the RFH header twice.
If you want to use the offset when reading the message again, reset to start of buffer before using your read.
Anyway I would use JMS. No hassles with RFH header there.
And with MQ Version 6 it even does targetClientMatching....
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Canimus |
Posted: Tue Oct 02, 2007 8:32 am Post subject: How did you read the MQRFH2 Header? |
|
|
Newbie
Joined: 02 Oct 2007 Posts: 1
|
Hi,
I'm trying to read the header of a message in a Java Client Application.
I can retrieve the message fromthe Queue successfully but when open the message the first bytes I get are:
RFH ???????????(MQSTR ????????3???<mcd>.....
Is there any method to determine the size of the header?
Thanks,
HV _________________ HV |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 02, 2007 2:20 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Read the manual. The size of the header is contained in the fixed portion at the begining of the header.
However I would not reinvent the wheel. Either move to JMS (no RFH header hassles, all handled behind the scenes through JMS) or ask your sending JMS app to define its queues as target client = MQ (?targetClient=1).
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|