10 Replies Latest reply on Feb 16, 2011 5:22 AM by Aaron Harshbarger

    dead letter queue on JBoss 6.0.0

    zappee zappee Newbie

      Dear All,

       

       

      I am new in JBoss and I would like to get some help about queue handler onJBoss 6.

       

      At my workplace I use weblogic app server, and it has a useful jms feature.Its name is redelivery. This function has three parameters:

       

      1. Redelivery Delay     Override: The number of milliseconds (between 0 and a positive 64-bit     integer) before rolled back and recovered messages are redelivered.
      2. Redelivery Limit: The     number of redelivery tries (between 0 and a positive 32-bit integer) a     message can have before it is placed in the error destination. If no JMS     template is configured, then -1 means that there is no override.
      3. Error Destination:     Destination for messages that have reached their redelivery limit, or for     expired messages on the destination where the expiration policy is     Redirect.

       

      I use redelivery function on Weblogic for prevent data lost and the theme specified error queue is comfortable for IT operators. The redelivery on weblogic works when an error occurs in the MDB (message driven bean) during run business logic. If there is an error then onMessage method of MDB throw aRuntimeException and the app server containers roll back data to the original JMS queue. After a couple of time the queue consume data and the MDB try to run the business logic aging and again. The MDB makes some same cycle (itdepend on redelivery limit) and the message is going to delivery to the error destination jms queue.

       

      So, I want to make this functionality on JBoss 6.0.0 application server. I have read documents and a see there is a dead letter on JBoss and it is same to redelivery function on weblogic server. I have written some example MDBs but the redelivery function is not working very well.

      I show you my JBoss configuration files and my code of message driven bean. Please point at my mistake(s) in my code.

       

      Thank you very much.

       

       

      Here is my queue config in <jboss_6.0.0_home>/server/default/deploy/hornetq/hornetq-jms.xml file:

       

      <configuration ...>

         ...

         <!-- the queue used by the example -->

         <queue name="exampleQueue">

            <entryname="/queue/exampleQueue"/>

         </queue>

       

         <!-- the dead letter queue where dead messages will be sent-->

         <queue name="deadLetterQueue">

            <entryname="/queue/deadLetterQueue"/>

         </queue>

       

      </configuration>

       

       

      Code of my message driven bean:


      @MessageDriven(name = "DLQExample",

                                activationConfig = { @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),

                                                            @ActivationConfigProperty(propertyName= "destination",propertyValue="/queue/exampleQueue") })

      //@Pool(value=PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize=1)

      @TransactionManagement(value= TransactionManagementType.CONTAINER)

      @TransactionAttribute(value= TransactionAttributeType.REQUIRED)

      @ResourceAdapter("jms-ra.rar")

      //@ResourceAdapter("hornetq-ra.rar")

       

      public class DLQExampleimplements MessageListener

      {

       

         public void onMessage(Message message)

         {

             try

             {

                 // I know theclient is sending a text message

                 TextMessagetextMessage = (TextMessage)message;

                 String text =textMessage.getText();

       

       

                System.out.println("received message:\n " + text);

       

                 if (text.contains("+") )

                 {

                    System.out.println("throw a forced exception to test my dead letterqueue");

                     throw new Exception("my forced exception");

                 }

             }

             catch (Exception e)

             {

                 throw newRuntimeException(e);

             }

         }

      }

       

       

      After I dropped my first simple text message to "exampleQueue" with HermesJMS I see on the console that my MDB received the message and run it well.

      My second message contains a "+" character so my code is going to throw a forced exception. My message rolled back to the"exampleQueue" jms and some time ago (value of Redelivery Delay) my MDB received the message. And the process continues indefinitely and my text message could not go to my "deadLetterQueue".

       

      Could you tell me what is the wrong in my code?

       

      regards, zappee

       

        • 1. dead letter queue on JBoss 6.0.0
          jaikiran pai Master

          zappee zappee wrote:

           


          And the process continues indefinitely and my text message could not go to my "deadLetterQueue".

           

          Unfortunately, that's a bug https://issues.jboss.org/browse/JBAS-7950 which did not get fixed in time for JBoss AS 6.0.0.Final.

          • 2. dead letter queue on JBoss 6.0.0
            zappee zappee Newbie

            I am very said because I need to use dead letter queue. Without good working DLQ I can not use JBoss with HornetQ.

            I see, the regisered date this bug is 6/Apr/10. A long time ago...

            When will be corrected this bug?

             

            Does DLQ work in JBoss 5.1.0.GA?

            • 3. dead letter queue on JBoss 6.0.0
              zappee zappee Newbie

              Could you tell me that what do the people use instead of DLQ?

               

              Is it a not important function for people?

               

              Is there an alternative solution for DLQ on JBoss?

              • 4. dead letter queue on JBoss 6.0.0
                jaikiran pai Master

                zappee zappee wrote:

                 


                Does DLQ work in JBoss 5.1.0.GA?

                Yes, it does.

                 

                 

                zappee zappee wrote:

                 

                I see, the regisered date this bug is 6/Apr/10. A long time ago...

                When will be corrected this bug?

                 

                 

                Hopefully in the next JBoss AS6 release.

                • 5. dead letter queue on JBoss 6.0.0
                  jaikiran pai Master

                  zappee zappee wrote:

                   

                  Could you tell me that what do the people use instead of DLQ?

                   

                  I've moved this thread to HornetQ forums to see if they can suggest a workaround.

                  • 6. dead letter queue on JBoss 6.0.0
                    zappee zappee Newbie

                    Thx!

                     

                    Could anybody suggest me a workaround or anything else?

                     

                    thx.

                    • 7. dead letter queue on JBoss 6.0.0
                      zappee zappee Newbie

                      Hi all,

                       

                      I try to use DLQ on JBoss 5.0.1.GA, and it is working wery well.

                       

                      I would like to summarize my working test solution for DQL usage on Joboss 5.0.1.GA.

                       

                      I put my queue definition xml file to <JBOSS_5.1.0.GA_HOME>/server/default/deploy/my-jms folder. Filename syntax: <PREFIX>-service.xml, my filename is queue-destinations-service.xml.

                       

                      <?xml version="1.0" encoding="UTF-8"?>

                       

                      <server>

                       

                         <mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=testDlqQueue" xmbean-dd="xmdesc/Queue-xmbean.xml">

                            <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                            <depends>jboss.messaging:service=PostOffice</depends>

                            <attribute name="SecurityConfig">

                               <security>

                                  <role name="guest" read="true" write="true"/>

                                  <role name="publisher" read="true" write="true" create="false"/>

                                  <role name="noacc" read="false" write="false" create="false"/>

                               </security>

                            </attribute>

                         </mbean>

                       

                         <mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=testQueue" xmbean-dd="xmdesc/Queue-xmbean.xml">

                            <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                            <depends>jboss.messaging:service=PostOffice</depends>

                            <!--<attribute name="JNDIName">com.remal.anitas.message_status_receiver_jmsq</attribute>

                            <attribute name="RedeliveryDelay">0</attribute>

                            <attribute name="MaxDeliveryAttempts">0</attribute>-->

                            <attribute name="DLQ">jboss.messaging.destination:service=Queue,name=testDlqQueue</attribute>

                            <attribute name="ExpiryQueue">jboss.messaging.destination:service=Queue,name=testDlqQueue</attribute> 

                            <attribute name="SecurityConfig">

                               <security>

                                  <role name="guest" read="true" write="true"/>

                                  <role name="publisher" read="true" write="true" create="false"/>

                                  <role name="noacc" read="false" write="false" create="false"/>

                               </security>

                            </attribute>

                         </mbean>

                        

                      </server>

                       

                       

                      Code of my test message driven bean:

                       

                       

                      package aa.bb;

                       

                      import javax.ejb.ActivationConfigProperty;

                      import javax.ejb.MessageDriven;

                      import javax.jms.Message;

                      import javax.jms.MessageListener;

                      import javax.jms.TextMessage;

                        

                      @MessageDriven(activationConfig =

                      {

                            @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),

                            @ActivationConfigProperty(propertyName="destination", propertyValue="queue/testQueue"),

                            @ActivationConfigProperty(propertyName="DLQMaxResent", propertyValue="10")

                      })

                       

                      //@Pool(value=PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize=1)

                      //@TransactionManagement(value= TransactionManagementType.CONTAINER)

                      //@TransactionAttribute(value= TransactionAttributeType.REQUIRED)

                       

                      public class MyDMBExample implements MessageListener

                      {

                         public void onMessage(Message message)

                         {

                             try

                             {

                                 // we know the client is sending a text message

                                 TextMessage textMessage = (TextMessage)message;

                                 String text = textMessage.getText();

                       

                                 System.out.println("-----------------------------------------------");

                                 System.out.println("message " + text + " received");

                                 System.out.println("-----------------------------------------------");

                                

                                 if ( text.contains("+") )

                                 {

                                     System.out.println("going to throw an forced exception");

                                     throw new Exception("forced exception");

                                 }

                             }

                             catch (Exception ex)

                             {

                                 System.out.println("Exgeption message: " + ex.getMessage() );

                                 throw new RuntimeException(ex);

                             }

                         }

                      }

                       

                       

                      regards, zappee

                      • 8. dead letter queue on JBoss 6.0.0
                        jaikiran pai Master

                        zappee zappee wrote:

                         

                        Hi all,

                         

                        I try to use DLQ on JBoss 5.0.1.GA, and it is working wery well.

                         

                        I would like to summarize my working test solution for DQL usage on Joboss 5.0.1.GA.

                         

                        If you really meant 5.0.1, then I would suggest that you upgrade to 5.1.0 version. There wer e many bugs fixed after 5.0.1 was released.

                        • 9. dead letter queue on JBoss 6.0.0
                          zappee zappee Newbie

                          Oh...

                          It is my mistake in my letter. I really use 5.1.0 version of JBoss.

                          Sorry

                          • 10. dead letter queue on JBoss 6.0.0
                            Aaron Harshbarger Newbie

                            Does this bug apply to the Expiry queue as well?  I'm using JBoss AS 6.0 Final and trying to have all my expired messages from a particular queue goto a expiry queue that has an MDB attached to it to process the expired messages.  If I send messages directly to the expiry MDB queue, it works great.  But for some reason, my expired messages don't get forwarded to the expiry MDB queue.

                             

                            Any ideas?

                             

                            Also, what are the alternatives for handling DLQ and Expiry (if broke as well) messages in JBoss 6.0?  I really don't want to be forced to move to JBoss 5.1?

                             

                            Any help appreciated.

                             

                            Thanks,

                            Aaron