我在 Jboss 7 应用程序中有一个 MDB,它充当 ActiveMQ 中队列的消费者。这就是从 JBoss 建立连接的方式
/subsystem=resource-adapters/resource-adapter=activemq-rar-5.6.0.rar/config-properties="ServerUrl":add(value="tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1")
在 MDB 上,这些是注释:
@MessageDriven(name = "MyConsumerMessageBean", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "maxSessions", propertyValue="2")})
@ResourceAdapter(value = "activemq-rar-5.6.0.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
当 JBoss 连接到 Active MQ 时,我看到 jms.prefetchPolicy.queuePrefetch=1 的值在连接尝试中传递给了 activeMQ 服务器,如 JBoss 服务器日志中所示。
2014-08-28 21:33:04,183 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-short-running-threads-threads - 3) Successfully established connection to broker [tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1]
但是,当我查看 ActiveMQ 队列屏幕并深入查看此使用者时,我看到 PreFetch Max Pending 列的值为 20。这个数字 20 来自哪里,为什么 ActiveMQ 不接受 1 的值。
我还尝试通过相同的机制设置其他值“jms.prefetchPolicy.all=1”,但这也不起作用。我在 JBoss AS 7.1.1 Final 和 ActiveMQ 5.6.0
谢谢