MessageListener not processing messages until publisher has
lupson Jun 12, 2006 4:56 AMHi all,
sorry if this has been up previously. I've searched the forums without finding anything about my issue, so here goes:
I have a JMS message provider (aka "Topic publisher") that delivers ObjectMessage(s) to a EJB 3.0 MessageDrivenBean (aka "Topic subscriber").
Let's say I publish five messages in a Stateless Session EJB 3.0 (called from a JSP page) using a while()-loop and then returns flow control to the caller, for example a simple JSP-page. In that case, everything works out just fine, the MessageListeners "onMessage( ..)" is invoked and the underlying business logic is called and so on.
My problem: If I wish to send a large number of messages in sequence, the MessageListener won't start processing the messages until the sender has finished sending all its messages - the while()-loop has ended and the method invoked in the Stateless Session EJB has finished.
Tried a variety of solutions:
* Inserting Thread.sleep every 5 messages for 10 seconds, to let the MessageListener "catch up". Does not work even if I let the thread sleep for several minutes.
* Creating new instances for the TopicFactory, TopicConnection, TopicSession and TopicPublisher for each individual message and closing them after each call to "publish". No difference.
* I've set max priority (9) on the messages, no luck either.
Until the message-creating SLSEJB method (having the while-loop) finishes, the subscriber won't start processing. Of course, I could be a bit patient and wait until all messages have been created. That works for up to a 10000-20000 messages. After that, the JVM reports OutOfMemoryException. (Running in JBoss-IDE). I've successfully sent about 15000 messages which then have been processed.
The thing I havn't tried is transaction management for the publisher, maybe creating small transactions for perhaps 10 messages at a time. Thinking of it, maybe the SLSEJB transacts the whole method invocation before actually sending the messages. Should have a look into that, Im not that familiar with that part of Session Beans.
Im running jboss-4.0.4.GA in EJB 3.0 configuration.
Anyone have the slightest idea how I can get the MessageListener to start processing messages concurrently with the publisher sending messages? Note that the Stateless Session EJB and MessageListener runs in the same JBoss instance.
Of course I could have the SL EJB call the underlying business logic of the MessageListener directly using RMI or whatever, same JVM and all, but this is part of a "proof of concept" I'm creating for use in our business.
Kind regards and thanks in advance for any answers.