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

查看:24
本文介绍了如何限制侦听 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 条消息时,它运行良好.所有邮件都由 5 个不同的 MDB 实例同时接收,因此我有 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 版本:

Here is the Jboss version:

[服务器] 发布 ID:JBoss [Trinity] 4.2.3.GA(版本:SVNTag=JBoss_4_2_3_GA 日期=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天全站免登陆