The following is the API that would be needed to access the data in the queue
- select the column where the message is store in serialized form.
- Use the following
TO Deserialize (Fetching serialized data from queue):
Message msg = Util.deserialize((Serializable) Encoding.decodeToObject(result.getString("MSG")));
This would return object of type JBOSS Message.
Hope this helps. Let me know if you still need more details.
I am guessing the result.getString is from "message" table - while my messages are in JBM_MSG table. I tried converting Blob to string and tried decoding it - but blew-up NullPointerEx.
The way the Message object gets stored in both the tables is quite similar, hence the method of retrieval would also be similar. I am not sure as to why you would be getting a null pointer exception. I had an entire redelivery model designed based on the retrieval and storage of data. It works like charm. Could you describe the way you are trying to retrieve it. meanwhile I will also try the same and will confirm you as early as possible.
this is how I tried -
I have a prepared statement for getting the payload out from DLQ
"select PAYLOAD from JBM_MSG msg where MESSAGE_ID in (Select message_ID from JBM_MSG_REF where channel_id = (select channel_id from JBM_POSTOFFICE where queue_name=?))";
Gives me a resultset back - the payload is BLOB...like below
Blob blob = rs.getBlob(1);
byte bytes = null;
bytes = blob.getBytes(0L, (int)blob.length());
bytes = rs.getBytes(1);
String s = new String( bytes, "UTF-8" );
Message msg = Util.deserialize((Serializable) Encoding.decodeToObject(s));
blows up nullpointerex here in Encoding class
public static Serializable decodeToObject (String param) throws IOException, ClassNotFoundException
if (param == null)
throw new IllegalArgumentException();
ContextObjectInputStream ois = null;
ByteArrayInputStream bs = new ByteArrayInputStream(Base64.decodeBase64(param.getBytes()));
ois = new ContextObjectInputStream(bs);
return (Serializable) ois.readObject();
ois.close(); // NullPointerException
must be something wrong with Encoding I pass.
Refer the JDBCPersistenceManager class ('getMessages' method) in "jboss-messaging.jar" (download the source related to your jboss version). This shows how to convert the payload to the added message type. I have done it for MapMessages.
perfect - I think its working now - I could deserialize few messages - I will run few more tests and see if its consistent. thnks a lot. the "message" table and jbm_msg table payload structures are different and Base64 decoding doesnt work similar way. I will add more details later.
I'am getting the same problem and don't success in solving it.
Can share the solution you find ?
Thaks a lot,
Can you please elaborate the problem? I had a wrong jar in my classpath which was blowing NullPointerEx while deserializing the Message.