-
1. Re: REST Interface, durable push subscriptions doesn't work
gaohoward Nov 13, 2012 10:54 PM (in response to fcosfc)Can you provide more information about jboss server and hornetq versions?
-
2. Re: REST Interface, durable push subscriptions doesn't work
fcosfc Nov 14, 2012 6:55 AM (in response to gaohoward)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 Nov 14, 2012 8:29 AM (in response to fcosfc)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 Nov 15, 2012 8:04 AM (in response to gaohoward)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>
- Deploy the HornetQ REST Interface: https://docs.google.com/open?id=0BxIsXB00A5yPV0hDODdqZUdVenM
- I've prepared a client in order to do the tests: https://docs.google.com/open?id=0BxIsXB00A5yPVHFua3J3dUV4dDQ : you can send a test message by running the class PostOrder and test the interface by receiving it, running ReceiveOrder
- Here you have the remote REST consumer: https://docs.google.com/open?id=0BxIsXB00A5yPZ3Z6Wk1jVmYwZVE It simply writes the received messages on the server log. I've deployed on a GlashFish Server 3.1.2.1, running on then port 8082. You can test the consumer by running PutOrderRemote on the client and reviewing the Glassfish log.
- In order to register de push subscription, execute the class PushReg on the client.
- If all is ok, you can send messages by running PostOrder and see them on the Glassfish log.
Best regards,
Paco Saucedo.
-
5. Re: REST Interface, durable push subscriptions doesn't work
gaohoward Nov 15, 2012 8:27 AM (in response to fcosfc)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 Nov 15, 2012 11:22 AM (in response to gaohoward)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 Nov 19, 2012 9:46 AM (in response to fcosfc)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 Nov 19, 2012 12:02 PM (in response to gaohoward)Hi Howard,
Yes, it is.
Best regards,
Paco.
-
9. Re: REST Interface, durable push subscriptions doesn't work
gaohoward Nov 20, 2012 3:35 AM (in response to fcosfc)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 Nov 20, 2012 11:23 AM (in response to gaohoward)Hi Howard,
Thank you very much.
Best regards,
Paco.