如何限制侦听Jboss JMS队列的MDB实例的数量 [英] How to limit the number of MDB instances listening to a Jboss JMS queue

查看:132
本文介绍了如何限制侦听Jboss JMS队列的MDB实例的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下设置上遇到问题:

I'm having a problem with the following setup:

一个Java应用程序将电子邮件消息发送到JMS队列,然后侦听队列的MDB使用onMessage方法获取电子邮件消息,它在Gmail SMTP上打开连接,将电子邮件发送到SMTP并关闭该连接.在JMS队列中的所有消息上执行此操作.

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.

当我同时在队列中有5条消息时,它的工作效果很好. MDB的5个不同实例同时提取所有邮件,因此我有5个并发连接到Gmail SMTP服务器.但是,当JMS队列中还有更多邮件时,我收到来自Gmail SMTP服务器的连接错误.前5条消息已正确发送,但其余消息未正确发送,因此其他消息丢失了,因为它们不再在队列中.

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.

所以我的问题是,是否可以限制将侦听JMS队列的MDB实例的数量?如果我最多有5个MDB,那么即使队列中有1000条消息,清空队列也将花费更长的时间,但至少我不会丢失任何消息.

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.

这是Jboss版本:

[服务器]版本ID:JBoss [Trinity] 4.2.3.GA(内部版本:SVNTag = JBoss_4_2_3_GA date = 200807181417)

[Server] Release ID: JBoss [Trinity] 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)

和MDB的配置如下:

@MessageDriven(activationConfig = {   
  @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ),   
  @ActivationConfigProperty( propertyName = "destination", propertyValue = "queue/emailQueue")  
})

您需要更多吗?

谢谢

编辑2011-02-14
可能我想限制MDB实例的数量是完全错误的.我看到了有关JMS线程数的配置.如果我限制了要发布到MDB的线程数,也许它将解决我的问题? JMS是否会等到MDB可用后再发布msg?有任何副作用吗?你虽然请. 谢谢
结束编辑

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 again? Is there any side effect to do that? Your though please. Thanks
END EDIT

推荐答案

尝试其他激活配置属性:

Try an additional acitivation config property:

@ActivationConfigProperty( propertyName = "maxSession", propertyValue = "someNumber")

其中someNumber是所需的最大实例数.

where someNumber is the maximum number of instances you want.

这篇关于如何限制侦听Jboss JMS队列的MDB实例的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆