我们有一个正在使用的应用程序JMS Queue
和一个MDB
. 我希望一次只能向MDB
from发送一条消息Queue
。我的意思是,一旦MDB
收到来自 的消息Queue
,它应该暂停Queue
并且一旦处理完成,Queue
应该恢复 。我可以为此编写代码吗,MDB
或者我可以进行任何配置ejb-jar.xml
吗?
问问题
894 次
2 回答
0
Implement your MDB as:
@MessageDriven(name = "SingleThreadedMdb ", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/myQueue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
@ActivationConfigProperty(propertyName = "consumerWindowSize", propertyValue = "0")
})
public class SingleThreadedMdb implements MessageListener {
@Override
public void onMessage(Message message) {
}
}
Configure the queue in standalone-full.xml
as:
<address-setting match="jms.queue.myQueue">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<max-delivery-attempts>1</max-delivery-attempts>
<max-size-bytes>10485760</max-size-bytes>
<address-full-policy>BLOCK</address-full-policy>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
</address-setting>
Under jms destinations add:
<jms-queue name="myQueue">
<entry name="/queue/myQueue"/>
<durable>true</durable>
</jms-queue>
于 2012-11-14T13:34:17.093 回答