-
15. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
timfox May 13, 2010 2:07 PM (in response to jimjohnson)It is illegal to create a consumer from inside an MDB and call receive() on it.
-
16. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
timfox May 13, 2010 2:11 PM (in response to timfox)To add a little more info: It's prohibited in the JEE spec, and for good reason.
JCA may cache sessions, but it does not cache consumers. This would mean you're creating a new producer and consumer every time ==> slow and anti-pattern.
-
17. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
jimjohnson May 13, 2010 2:34 PM (in response to timfox)Not using an MDB, just a standard Service (annotated @org.jboss.annotation.ejb.Service class). Maybe that's illegal in HornetQ too though? This code worked fine w/ JBoss Messaging. I know it was illegal to create a consumer in an MDB like that in JBoss Messaging as well.
Like it said, the receive calls also return if I use the HornetQRAConnectionFactory vs. the HornetQConnectionFactory for creating all my connection/session/producer/consumer objects. It's just the wrong type of object that comes back.
I've walked through the whole chain in a debugger now. I see my management call making it into ServerSessionImpl.handleManagementMessage(). I see that code getting the 'replyTo' correctly and the 'replyTo' being the temporary queue that was created in the service. I see that chaining down into PostOfficeImpl.route(ServerMessage, RoutingContext). I see that code finding Bindings and calling Bindings.route which gets into LocalQueueBinding.route()... etc etc. I just never actually get a Message back from my receive call, it eventually hits my EJB transaction timeout and causes exceptions.
After typing this I tried one more thing. I set my session to be non-transacted instead of transacted. This caused my receive to return... but I'm not really sure why...
-
18. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
jimjohnson May 13, 2010 2:54 PM (in response to jimjohnson)So I guess the only difference is that before (when using JBoss Messaging), to get the MessageCount of the queue the code was using an MBeanServer to get the "MessageCount" property of the given queue. That didn't care about my current transaction. Since switching to HornetQ and using the Management API, I can't have a send Message w/ ReplyTo then receive from ReplyTo within the same transaction. Might be a pretty standard thing actually as I seem to recall running into a similar issue w/ JBoss Messaging awhile back. I think I got around it then but throwing a NOT_SUPPORTED transaction attribute on the method... maybe something like that will work for me here too. I'll have to check. Thanks for all your help guys, I'll post a follow up here once I figure out more to hopefully help someone else out in the future as well.
-
19. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
timfox May 13, 2010 3:59 PM (in response to jimjohnson)You can't send and expect to receive the same message in a single tx.
The message won't actually get sent until you call commit() which is after the point you wish to receive it.
This is nothing specific to HornetQ.
-
20. Re: Cannot send a non JBoss message as a management message org.hornetq.ra.HornetQRAMessage
jmesnil May 17, 2010 3:57 AM (in response to jimjohnson)Jim Johnson wrote:
So I guess the only difference is that before (when using JBoss Messaging), to get the MessageCount of the queue the code was using an MBeanServer to get the "MessageCount" property of the given queue.
You can still use JMX to manage HornetQ and know the number of messages for the queue: http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/management.html#management.jmx