I'm having a problem with the following setup:
A Java application send email msg to a JMS queue, then an MDB listening to the queue get the email msg with the onMessage method, it open a connection on the Gmail SMTP, send the email to the SMTP and close the connection. Doing this on all message in the JMS queue.
It is working great when I have up to 5 messages in the queue at the same time. All messages are picked-up in the same time by 5 different instances of the MDB, so I have 5 concurrent connection to the Gmail SMTP server. But when there is more messages in the JMS queue, I get a connection error from the Gmail SMTP server. The 5 first messages are sent correctly, but not the rest of the bunch, so the other messages are lost because they are not in the queue anymore.
So my question is, is it possible to limit the number of MDB instance that will listen to the JMS queue? If I have a maximum of 5 MDB, then even if I have 1000 messages in the queue, it will just take longer to empty the queue, but at least I wont lose any message.
Any other suggestion to resolve this issue would be very much appreciated.
Here is the Jboss version:
[Server] Release ID: JBoss [Trinity] 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)
and the config of the MDB is as following :
@MessageDriven(activationConfig = {
@ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ),
@ActivationConfigProperty( propertyName = "destination", propertyValue = "queue/emailQueue")
})
Do you need more?
Thanks
EDIT 2011-02-14
Maybe I'm all wrong wanting to limit the number of MDB instance. I saw a config about the number of JMS threads. If I limit the number of thread that will post to the MDB, maybe it will resolve my issue? Will the JMS wait until a MDB is available before posting msg a开发者_运维知识库gain? Is there any side effect to do that? Your though please. Thanks END EDITTry an additional acitivation config property:
@ActivationConfigProperty( propertyName = "maxSession", propertyValue = "someNumber")
where someNumber is the maximum number of instances you want.
If JBoss 4 has an option to limit the instances of a stateless session bean, one option could be to move the message processing code to this bean, and pass the incoming JMS messages to it. (IIRC any failures in the bean would also cause the JMS message to be unacknowledged so it would retry automatically).
精彩评论