1 2 Previous Next 19 Replies Latest reply on May 20, 2010 10:49 AM by dfisher

    Durable messages and MDB with selector

    dfisher

      Testing JBoss 5.1.0 + Hornetq 2.1.0Beta3.

      I have a topic with a durable subscription (MDB) that uses a message selector.

      Shutting down JBoss with messages waiting to be ACK'd in the topic results in the messages being lost when the server starts.

       

      If I remove the message selector from the MDB the messages are processed as expected when the server starts.

      (Without the appropriate selecting....)

       

      hornetq-configuration.xml:

       

      <address-settings>
            <address-setting match="#">
               <dead-letter-address>jms.queue.DLQ</dead-letter-address>
               <expiry-address>jms.queue.ExpiryQueue</expiry-address>
               <redelivery-delay>5000</redelivery-delay>
               <max-delivery-attempts>-1</max-delivery-attempts>
               <message-counter-history-day-limit>10</message-counter-history-day-limit>
            </address-setting>
            <address-setting match="jms.topic.DurableTopic">
               <max-size-bytes>104857600</max-size-bytes>
               <page-size-bytes>10485760</page-size-bytes>
               <address-full-policy>PAGE</address-full-policy>
            </address-setting>
         </address-settings>

       

      hornetq-jms.xml:

       

      <topic name="DurableTopic">
            <entry name="/topic/DurableTopic"/>

      </topic>

       

      MDB:

       

      @MessageDriven(
        messageListenerInterface = MessageListener.class,
        activationConfig = {
          @ActivationConfigProperty(
            propertyName = "destination",
            propertyValue = "topic/DurableTopic"
          ),
          @ActivationConfigProperty(
            propertyName = "destinationType",
            propertyValue = "javax.jms.Topic"
          ),
          @ActivationConfigProperty(
            propertyName = "acknowledgeMode",
            propertyValue = "AUTO_ACKNOWLEDGE"
          ),
          @ActivationConfigProperty(
            propertyName = "subscriptionDurability",
            propertyValue = "Durable"
          ),
          @ActivationConfigProperty(
            propertyName = "maxMessages",
            propertyValue = "1"
          ),
          @ActivationConfigProperty(
            propertyName = "maxSession",
            propertyValue = "1"
          ),
          @ActivationConfigProperty(
            propertyName = "useDLQ",
            propertyValue = "true"
          ),
          @ActivationConfigProperty(
            propertyName = "subscriptionName",
            propertyValue = "Test-Durable"
          ),
          @ActivationConfigProperty(
            propertyName = "clientID",
            propertyValue = "durable-1"
          ),
          @ActivationConfigProperty(
            propertyName = "messageSelector",
            propertyValue = "DurableSelector = 'test-durable'"
          )
          }
      )
      @TransactionManagement(value = TransactionManagementType.CONTAINER)
      @TransactionAttribute(value = TransactionAttributeType.REQUIRED)
      @ResourceAdapter("hornetq-ra.rar")
      public class TestDurableBean implements MessageListener

       

      Am I missing something from my configuration?

      Anyone else seen this problem?

      Thanks.

        • 1. Re: Durable messages and MDB with selector
          clebert.suconic

          If you could replicate this is a test case...

          • 2. Re: Durable messages and MDB with selector
            dfisher

            Sure, wanted to make sure this wasn't a known issue before I continued.

             

            Here are the procedures to reproduce this:

              - start JBoss 5.1.0 using hornetq2.1.0Beta3

                * hornetq security off

                * deploy a topic at /topic/ExampleTopic

                * configure a logging appender for org.hornetq package

              - deploy the supplied ear

                * it contains 2 MDBs, one with a selector and one without

              - execute the supplied script which enqueues 2 messages, one of which will match the selector

             

            ./run.sh 127.0.0.1 # or where ever JBoss is listening

              - confirm the messages were received in the org.hornetq log

              - undeploy the supplied ear

              - execute the script again

              - access the jmx-console and confirm 3 messages are in ExampleTopic

              - deploy the supplied ear

                * check the org.hornetq log to confirm 2 message were logged for  DurableNoSelectorMDB

                * check the org.hornetq log to confirm no message were logged for DurableSelectorMDB

                * check the jmx-console to confirm the message was lost

             

            You should see the following hornetq error:

             

            ERROR [org.hornetq.ra.inflow.HornetQActivation] (WorkManager(2)-8) Unable to start activation
            javax.jms.IllegalStateException: Cannot create a subscriber on the durable subscription since it already has subscriber(s)
                at org.hornetq.ra.inflow.HornetQMessageHandler.setup(HornetQMessageHandler.java:121)
                at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:287)
                at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:502)

             

            I see this exception frequently with MDBs, but I've never assoicated it with message loss until now.

            Messages enqueued after the deploy are consumed as expected.

            • 3. Re: Durable messages and MDB with selector
              timfox

              Try TRUNK. I believe that has been fixed since 2.0

              • 4. Re: Durable messages and MDB with selector
                dfisher

                Tested with TRUNK, I got the same results.

                • 5. Re: Durable messages and MDB with selector
                  dfisher

                  This problem appears specifc to MDBs, I do not see this behavior with message listeners.

                  • 6. Re: Durable messages and MDB with selector
                    dfisher
                    • 7. Re: Durable messages and MDB with selector
                      timfox

                      I guess I am missing something, but I am struggling to understand what this issue is.

                       

                      If you have an MDB on a topic with a selector, and you send some messages to the topic which do not match the selector, then those messages will indeed be "lost". This is however expected behaviour.

                       

                      The messages will not enter the durable subscription unless they match.

                      • 8. Re: Durable messages and MDB with selector
                        dfisher

                        I'm publishing messages that both match and don't match the selector to illustrate that the problem appears to be specific to MDBs with selectors.

                        This test could be simplified by removing the subscriber without a selector, but I didn't feel this was overly complex.

                         

                        2 messages are published to the topic, one of which matches the selector.

                        This results in 3 messages waiting in the topic for 2 subscribers.

                        The MDB without the selector consumes it's two messages after redeploy.

                        The MDB with the selector never consumes it's message after redeploy and the message disappears from the topic.

                         

                        So after redeploy the MDB with the selector does not see the message that was waiting for it.

                        Does that make sense?

                        • 9. Re: Durable messages and MDB with selector
                          timfox

                          Maybe I'm slow, but it's not making sense to me.

                           

                          I'm not sure what you mean by "messages waiting in the topic". Topics do not contain some kind of waiting area or holding queue which stores messages prior to delivery to consumers.

                           

                          A topic is simply a set of subscriptions, some durable, some not which may or may not have selectors. When a message is sent to a topic it either goes into a particular subscription if it matches, or it does not. If no subscriptions match the message is "lost". This is normal topic behaviour.

                          • 10. Re: Durable messages and MDB with selector
                            dfisher

                            Let me rephrase then.

                            Messages in a durable subscription that is using a selector are lost on redeploy.

                             

                            Have you attempted to reproduce this?

                            I think it will be clear when you see 3 messages in the jmx-console and only 2 consumed when the ear is redeployed.

                            • 11. Re: Durable messages and MDB with selector
                              timfox

                              It seems to me the other MDB without the selector is irrelevant to this issue, and just serves to complicate the picture.

                              • 12. Re: Durable messages and MDB with selector
                                timfox

                                To clarify, what you're saying is:

                                 

                                You have a durable subscription with a selector and an MDB consuming from it.

                                 

                                You send some messages to the topic which match the selector, the MDB hasn't consumed them yet.

                                 

                                You restart the server.

                                 

                                The messages have "disappeared".

                                 

                                Correct?

                                • 13. Re: Durable messages and MDB with selector
                                  dfisher

                                  I tested undeploy/deploy, not restart.

                                  The behavior may or may not be the same.

                                   

                                  Correct to everything else.

                                  • 14. Re: Durable messages and MDB with selector
                                    ataylor

                                    for some reason your MDB's are being deployed twice each (see below)

                                     

                                    can you double check you ear or provide buildable src.

                                     

                                    13:12:50,164 INFO  [EJBContainer] STARTED EJB: org.hornetq.test.mdb.DurableNoSelectorMDB ejbName: DurableNoSelectorMDB
                                    13:12:50,566 INFO  [EJBContainer] STARTED EJB: org.hornetq.test.mdb.DurableNoSelectorMDB ejbName: DurableNoSelector
                                    13:12:51,025 INFO  [EJBContainer] STARTED EJB: org.hornetq.test.mdb.DurableSelectorMDB ejbName: DurableSelectorMDB
                                    13:12:51,330 INFO  [EJBContainer] STARTED EJB: org.hornetq.test.mdb.DurableSelectorMDB ejbName: DurableSelector

                                    1 2 Previous Next