我们在消息驱动 Bean (MDB) 中遇到了问题。当MDB
同时接收到多条消息时,开始乱序处理消息。 (执行顺序与接收顺序不同)
例如:
消息的原始顺序:消息 1、消息 2、消息 3
但在应用程序级别 onMessage()
调用顺序不正确。
例如:消息 2、消息 1、消息 3
我们在 MDB
中使用 EJB3
消息驱动注释,而 Jboss
版本为 Jboss EAP 6.4
,实现为 HornetQ
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/Queue1"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "-1"),
@ActivationConfigProperty(propertyName = "minSessions", propertyValue = "1"),
@ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "1"),
@ActivationConfigProperty(propertyName = "maxMessagesPerSessions", propertyValue = "1"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}, name = "MessageDrivenBeanEJB")
如何确保消息消费顺序与接收顺序相同?
最佳答案
您的 HornetQ 配置属性名称不正确。尝试一下
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
您应该找出您指定的其他哪些对于 HornetQ 来说是正确的,因为这些看起来像是来自早期 JBoss Messaging 化身的参数。
关于java - Jboss 中的乱序消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31049423/