Author |
Message
|
hi.riyazkhan |
Posted: Wed Jul 18, 2012 2:16 am Post subject: How to fetch Message Body from MQ message stored in CLOB |
|
|
Newbie
Joined: 18 Jul 2012 Posts: 7
|
Hi,
I am new to Websphere MQ.
In our application we have a Full MQ message (i.e. MQMD + RFH2 + message body) received and stored in DB in CLOB column.
Now I need to parse this CLOB data to extract just the message body part (same data we get by calling getText() on JMSTextMesage).
The issue is messages coming in CLOB can come from different systems and may have various RFH2 Header values and different message formats.
Could someone please tell me how to go about this, or how should I parse the CLOB.
Thanks in advance. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jul 18, 2012 4:31 am Post subject: Re: How to fetch Message Body from MQ message stored in CLOB |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
hi.riyazkhan wrote: |
Could someone please tell me how to go about this, or how should I parse the CLOB. |
You have 2 options:
1) Ask whoever wrote the application that stored the message in the database what method they expected someone to use to retrieve the message
2) Write some application code to parse the CLOB. All of the headers are documented so it's easy enough so walk through the MQMD & RFH2(s) to get to the message body. Remember that each header is chained so that it describes the one following it, so when you find a description that doesn't describe a header you've found the body. Also remember that the RFH2 is variable length. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jul 18, 2012 8:50 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
AFAIK the MQMessage object is serializable. So if what is stored is a serialized object, all you need to do is to unserialize it (unmarshal) and then just treat it as an MQMessage that you cast to TextMessage...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
hi.riyazkhan |
Posted: Wed Jul 18, 2012 8:56 pm Post subject: |
|
|
Newbie
Joined: 18 Jul 2012 Posts: 7
|
Thanks a lot for the replies...
@Saper.. Actually I too thought of the same initially, however its not serialized object. the other application people sent some lines of code and looked like they store messages through some script(I think its IBM MQ's Script but not sure, it did not look very familiar script/language though).
@Vitor ... 1st option won't work in our case ase the application storing the CLOB is meant for tracking only and stores the message irrespective of format of the messaage and expects no differentiation in the header and body
2nd option looks more relevant, however unfortuantely I am not aware in detail about the sequencing of the header folders in RFH2 and MQMD.
I tried skimming through the IBM docs, however couldnt find what exactly I need. Could you please tell me where can I find brief tutorial on sequencing of folders or give an example for traversing the MQMD and RFH2.
Thanks in advance... |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jul 18, 2012 9:04 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
you first need to familiarize yourself with the header chaining concept.
All headers following the MQMD are placed into the payload....
The MQMD FORMAT field tells you what the next section (payload) looks like.
If it says MQFRH2 or something like that you need to read x bytes of the message (enough to get the format and length fields of the RFH header.
This in turn will tell you the length of the current section (RFH header) and the format of the next section...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Jul 18, 2012 11:37 pm Post subject: Re: How to fetch Message Body from MQ message stored in CLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
hi.riyazkhan wrote: |
In our application we have a Full MQ message (i.e. MQMD + RFH2 + message body) received and stored in DB in CLOB column. |
CLOB is a character data type. The WMQ headers contain non-character data. If the message has different formats, it may also contain non-character data. The application storing the message in the database would have to transform the message first, to map the non-character data to characters. The application retrieving the message from the database would have to know how that was done, so it could apply a reverse transformation. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 19, 2012 5:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
hi.riyazkhan wrote: |
@Vitor ... 1st option won't work in our case ase the application storing the CLOB is meant for tracking only and stores the message irrespective of format of the messaage and expects no differentiation in the header and body |
If it's meant for tracking, how did the designer intend anyone to extract the tracking data?
hi.riyazkhan wrote: |
I tried skimming through the IBM docs, however couldnt find what exactly I need. |
Try reading them instead.
hi.riyazkhan wrote: |
Could you please tell me where can I find brief tutorial on sequencing of folders or give an example for traversing the MQMD and RFH2. |
It's called "developing code", which you do by studying the documentation and working things out. The explaination given by my most worthy associate is more than enough to get you started. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|