10 Replies Latest reply on Nov 20, 2012 11:23 AM by fcosfc

    REST Interface, durable push subscriptions doesn't work

    fcosfc

      Hi there,

       

         I've successfully created a durable push subscription at runtime using the REST interface, but when I restart the JBoss server the interface doesn't start to transfer messages, although I can read the following register on the log:

       

      17:08:24,125 INFO  [FilePushStore] Loading REST push store from: C:\TEMP\HornetQ\queue-push-store

      17:08:24,125 INFO  [FilePushStore] adding REST push registration: 1234

       

         I also tried to create a subscription by hand with the same result.

       

         Here you have an excerpt of the REST interface manual:

       

      "...The durable element specifies whether the registration should be saved to disk so that if there is a server restart, the push subscription will still work. This element is not required. If left out it defaults to false. If durable is set to true, an XML file for the push subscription will be created within the directory specified by the queue-push-store-dir config variable defined in Chapter2. (topic-push-store-dir for topics)..."

       

         and my configuration:

       

      <push-registration id="1234">

        <destination>jms.queue.Test.TestQueue</destination>

        <durable>true</durable>

        <link href="http://localhost:8081/ReceptorTest/webresources/receptor" method="PUT"/>

      </push-registration>

       

      Do your have any ideas about this issue?

        • 1. Re: REST Interface, durable push subscriptions doesn't work
          gaohoward

          Can you provide more information about jboss server and hornetq versions?

          • 2. Re: REST Interface, durable push subscriptions doesn't work
            fcosfc

            Hi Yong,

             

               The version of my JBoss Application Server is 4.2.1 GA and I'm using HornetQ 2.2.5.

              

               I tried to run JBoss-4.2.1 GA with HornetQ 2.2.14 as its JMS provider but I got an exception:

             

            17:13:56,468 WARN  [ServiceController] Problem starting service jboss.jca:service=RARDeployment,name='jms-ra.rar'

            java.lang.NoClassDefFoundError: org/jboss/tm/XAResourceRecovery

                      at org.hornetq.ra.recovery.RecoveryManager.locateRecoveryRegistry(RecoveryManager.java:131)

                      at org.hornetq.ra.recovery.RecoveryManager.start(RecoveryManager.java:55)

                      at org.hornetq.ra.HornetQResourceAdapter.start(HornetQResourceAdapter.java:226)

                      at org.jboss.resource.deployment.RARDeployment.startService(RARDeployment.java:109)

                      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)

                      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

                      at org.jboss.system.ServiceDynamicMBeanSupport.invoke(ServiceDynamicMBeanSupport.java:124)

                      at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)

                      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)

                      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)

                      at $Proxy0.start(Unknown Source)

            ...

             

                Which it was reported like a bug of the version 2.2.14: https://issues.jboss.org/browse/HORNETQ-920 Unfortunately, I must use JBoss-4.2.1 in my project.

             

            Best regards,

             

            Paco Saucedo.

            • 3. Re: REST Interface, durable push subscriptions doesn't work
              gaohoward

              Yeah I believe 2.2.14 and later will only work with JBOSS 5. Anyway if you can give the steps to reproduce your original issue (using 2.2.5), I can help to investigate a bit more.

              • 4. Re: REST Interface, durable push subscriptions doesn't work
                fcosfc

                Hi Yong,

                 

                   Thank you very much for your interest. While I was preparing a test environment for you, I've realised that the push subscriber starts to send messages when I send the first message after a JBoss AS restart, so there is no problem with the issue of this post. But, I've checked that some older messages (duplicates) are sent at restart, which it is not desirable. Do you know any method to avoid this?

                 

                   Here you have the steps to setup my test environmet:

                 

                • Deploy the queue on JBoss 4.2.1 GA by adding the following configuration to your hornetq-jms.xml file:

                 

                   <queue name="orders">

                      <entry name="/queues/orders"/>

                   </queue>

                 

                 

                Best regards,

                 

                Paco Saucedo.

                • 5. Re: REST Interface, durable push subscriptions doesn't work
                  gaohoward

                  Thanks Paco for the instructions. I'll give it a try.

                   

                  When you say "older messages (duplicates) are sent at restart," do you mean that hornetq server delivers those message twice? were those messages acknowledged before restart? HornetQ server will re-deliver any non-acked messages on a restart.

                   

                  Howard

                  • 6. Re: REST Interface, durable push subscriptions doesn't work
                    fcosfc

                    Hi Yong,

                     

                       I've reviewed the code of the class org.hornetq.rest.queue.push.PushConsumer and the messages are acknowledged:

                     

                       @Override

                       public void onMessage(ClientMessage clientMessage)

                       {

                          if (strategy.push(clientMessage) == false)

                          {

                             throw new RuntimeException("Failed to push message to " + registration.getTarget());

                          }

                          else

                          {

                             try

                             {

                                log.debug("Acknowledging: " + clientMessage.getMessageID());

                                clientMessage.acknowledge();

                             }

                             catch (HornetQException e)

                             {

                                throw new RuntimeException(e);

                             }

                          }

                       }

                     

                       But, duplicates are sent at restart, please watch the following video where you can check that Paco's order is sent twice:

                     

                     

                       Maybe, a commit statement is needed?

                     

                    Best regards,

                     

                    Paco.

                    • 7. Re: REST Interface, durable push subscriptions doesn't work
                      gaohoward

                      Hi Paco,

                       

                      I followed your instructions and finally got it up and running. Here is what I observed:

                       

                      1. Using PushOrder and ReceiveOrder, messages are not resent after restart.

                      2. Using PushOrder and Remote consumer in Glassfish, I found if I sent a message after a restart of JBoss, all previous sent messages are sent again. For example is I send "order 1", the glassfish log shows "order 1" received. Then I restart jboss and send another, 'order 2', the glassfish log says it receives 'order 1' followed by 'order 2'.

                       

                      Is that what you see in your test?

                       

                      Howard

                      • 8. Re: REST Interface, durable push subscriptions doesn't work
                        fcosfc

                        Hi Howard,

                         

                           Yes, it is.

                         

                        Best regards,

                         

                        Paco.

                        • 9. Re: REST Interface, durable push subscriptions doesn't work
                          gaohoward

                          Hi Paco,

                           

                          I think you are right. The ack of a message in onMessage() method is not correct. It should be like:

                           

                           

                             public void onMessage(ClientMessage clientMessage)
                             {
                                log.debug(this + ": receiving " + clientMessage);
                          
                                try
                                {
                                   clientMessage.acknowledge();
                                   log.debug(this + ": acknowledged " + clientMessage);
                                }
                                catch (HornetQException e)
                                {
                                   throw new RuntimeException(e.getMessage(), e);
                                }
                          
                                log.debug(this + ": pushing " + clientMessage + " via " + strategy);
                                boolean acknowledge = strategy.push(clientMessage);
                          
                                if (acknowledge)
                                {
                                   try
                                   {
                                      log.debug("Acknowledging: " + clientMessage.getMessageID());
                                      session.commit();
                                      return;
                                   }
                                   catch (HornetQException e)
                                   {
                                      throw new RuntimeException(e);
                                   }
                                }
                                else
                                {
                                   try
                                   {
                                      session.rollback();
                                   }
                                   catch (HornetQException e)
                                   {
                                      throw new RuntimeException(e.getMessage(), e);
                                   }
                                }
                             }
                          

                           

                          Here is the Jira:

                           

                          https://issues.jboss.org/browse/HORNETQ-1091

                           

                          Thanks

                          Howard

                          • 10. Re: REST Interface, durable push subscriptions doesn't work
                            fcosfc

                            Hi Howard,

                             

                               Thank you very much.

                             

                            Best regards,

                             

                            Paco.