8 Replies Latest reply on Nov 2, 2012 3:08 PM by joe_boy12

    Question on DeadLetterQueue

    joe_boy12

      Hello folks,

       

      I have a requirement where failed messages (after certain retries) should go to a designated DLQ where Prod Support people can jump in and inspect the message. I am using jms-jca provider to have retry logic and activation config to move failed messages to DLQ. The problem is the messages in DLQ are jBoss serialized message and cannot be read easily. Prod Support team wants something handy where they can inspect the message, edit it and resend - I can write a listener on DLQ to convert it to plain text message and show it in JSP or UI but I will have to do it for each n every DLQ - my system has at least 50-60 DLQs. (for various interfaces) - I want some thing which can read from a DLQ - Deserialize it and edit it - I can use ServiceInvoker to serialize it and put in back in my pipeline flow. Has anybody dealt it with before? Any help would be greatly appreciated.

       

      Thnx

      Joe

        • 1. Re: Question on DeadLetterQueue
          raghav.vis

          Hello Joe,

           

           

           

          The following is the API that would be needed to access the data in the queue

           

           

          1. select the column where the message is store in serialized form.
          2. Use the following

           

          TO Deserialize (Fetching serialized data from queue):


          import org.jboss.internal.soa.esb.util.Encoding;

          import org.jboss.soa.esb.util.Util;

          import java.io.Serializable;

           

          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.

           

           

          Regards,

          Raghav.V


           

           


           


          • 2. Re: Question on DeadLetterQueue
            joe_boy12

            Thanks Raghav,

             

            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.

            • 3. Re: Question on DeadLetterQueue
              raghav.vis

              Hello Joe,

               

              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.

              • 4. Re: Question on DeadLetterQueue
                joe_boy12

                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;

                try
                {
                bytes = blob.getBytes(0L, (int)blob.length());
                }
                catch(Exception e)
                {
                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;

                try
                {
                  ByteArrayInputStream bs = new ByteArrayInputStream(Base64.decodeBase64(param.getBytes()));
                  ois = new ContextObjectInputStream(bs);

                  return (Serializable) ois.readObject();
                }
                finally
                {
                  ois.close(); // NullPointerException
                }
                }

                must be something wrong with Encoding I pass.

                 

                 

                 

                 

                • 5. Re: Question on DeadLetterQueue

                  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.

                  • 6. Re: Question on DeadLetterQueue
                    joe_boy12

                    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.

                    • 7. Re: Question on DeadLetterQueue
                      smamdy

                      Hello

                       

                      I'am getting the same problem and don't success in solving it.

                       

                      Can share the solution you find ?

                       

                      Thaks a lot,

                      Stséphane

                      • 8. Re: Question on DeadLetterQueue
                        joe_boy12

                        Can you please elaborate the problem? I had a wrong jar in my classpath which was blowing NullPointerEx while deserializing the Message.