第一次使用Jboss 7.2并尝试部署简单的MDB。 MDB注释为自动确认
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "/queue/test")
})
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@TransactionManagement(value= TransactionManagementType.CONTAINER)
public class TextMessageListener implements MessageListener {
onMessage很简单,只是睡觉和清醒。我的期望是,一旦MDB消耗了消息,即调用onMessage,它应该从Queue中删除。但是消息仍然在队列中,直到onMessage完成并且状态显示为“In Delivery”。
public void onMessage(Message message) {
System.out.println("sleeping for some time");
try {
Thread.sleep(10*60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("awake and done now");
}
当on-message完成时,日志显示确认在完成后发送,因此在onMessage完成后将从队列中删除消息。一些愚蠢的傻配置,因为它很简单。 ..但任何想法缺少什么。如何在JBOSS 7.2 MDB中设置autoacknowledgment,以便在调用onMessage时消息自动执行。
15:59:33,584 INFO [stdout] (Thread-3 (HornetQ-client-global-threads-467768789)) awake and done now
15:59:33,586 DEBUG [org.hornetq.core.client] (Thread-3 (HornetQ-client-global-threads-467768789)) client ack messageID = 1079
这很简单直接,但没有按预期工作。我们尝试使用一个消费者(一个独立的java测试客户端来读取队列中的消息)并在那里工作。
一旦消费者使用消息,即使消息处于消费者处理而不是MDB消息中,消息也会从队列中删除。
有什么想法吗?
我试图在JBoss社区提出同样的问题,但没有成功。希望有人会在这里回答..
提前致谢。
答案 0 :(得分:0)
我在Glassfish(v4.0)上尝试过类似的东西,并注意到我的mdb部署有问题(我有一个验证程序正在运行)。 glassfish日志文件抱怨"自动确认"无法识别的属性值。我做了以下更改,然后它起了作用:
更改自:propertyValue ="自动确认")
更改为:propertyValue ="自动确认")
请注意大小写 - 已更改为与ejb3.2规范中的列表匹配(第5.4.16.1节)。