|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Extracting original message data from DLQ using Java |
« View previous topic :: View next topic » |
Author |
Message
|
ktg |
Posted: Tue Apr 20, 2010 2:40 am Post subject: Extracting original message data from DLQ using Java |
|
|
Centurion
Joined: 09 Jan 2006 Posts: 138 Location: India
|
Hi,
Am trying to extract original messages from DLQ. Am following the same procedure given in
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/ja35160_.htm .
But, getting exception..
Here is my code :
MQMessage message = new MQMessage();
qHandle.get(message,gmo);
MQHeaderList klist = new MQHeaderList (message, true); // Step 1.
MQDLH kdlh = (MQDLH) klist.get (0); // Step 2.
int reason = kdlh.getReason (); // Step 3.
klist.remove (kdlh); // Step 4.
MQMessage newMessage = new MQMessage ();
klist.write (newMessage, true); // Step 5.
newMessage.format = klist.getFormat (); // Step 6.
byte[] kb = new byte[newMessage.getMessageLength()];
message.readFully(kb);
String kstr = new String(kb);
The java.io.EOFException is coming at line message.readFully(kb);
Pls help in resolving the problem.
Thanks,
Kalpana |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 20, 2010 9:11 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
ktg wrote: |
MQDLH kdlh = (MQDLH) klist.get (0); // Step 2. |
I would have thought that the DLQ header would be the second header in the list after MQMD... also did you deduct from kb the length of the header? If not did you reset the pointer to start again at the start of the message?
You used
Code: |
MQHeaderList klist = new MQHeaderList (message, true); // Step 1. |
which is supposed to read the body...
To access the body of the message you should now use
Code: |
Object body = klist.getBody(); |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ktg |
Posted: Tue Apr 20, 2010 10:28 pm Post subject: |
|
|
Centurion
Joined: 09 Jan 2006 Posts: 138 Location: India
|
Thanks fjb_saper for the reply.
The call
Quote: |
Object body = klist.getBody() |
worked.
Quote: |
I would have thought that the DLQ header would be the second header in the list after MQMD |
Its the first header. I am able to extract reason code, destination queue, etc., from kdlh.
Quote: |
did you deduct from kb the length of the header? If not did you reset the pointer to start again at the start of the message? |
In my code, I expected
Code: |
klist.remove (kdlh); |
would remove the deadletter header from header list. so ,
Code: |
klist.write (newMessage, true); |
would result in the original message which was being put to the dead letter queue without DLH. I thought I could read it from newMessage in the same way as if the message is from any other application queue. So, didn't deduct DLH size while reading kb also for the same reason didn't reset the pointer. Please, let me know if I am wrong.
Regards,
Kalpana |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 21, 2010 10:59 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Looks like the right way...
However you are going a long way to do something that is done so much easier by asking your MQ Admin to run a dead letter queue handler...
Have fun  _________________ 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
|
|
|
|