【发布时间】:2015-06-25 11:44:23
【问题描述】:
我们在消息驱动 bean (MDB) 中遇到了问题。当MDB同时收到多条消息时,开始乱序处理消息。 (执行顺序与接收顺序不同)
例如:
消息的原始顺序:Message 1, Message 2, Message 3
但在应用程序级别onMessage() 调用顺序不正确。
例如:Message 2, Message 1, Message 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")
如何确保消息消费顺序与接收顺序一致?
【问题讨论】:
-
您使用的是哪个队列以及您有多少个 MDB?
-
@Kayaman 哦,对不起,我应该提一下……我们正在使用 HornetQ。这取决于使用多少MDB?我们有 8 个用于不同功能的 MDB。实际上,我们不想担心其中 7 个队列中消息的顺序。但在其他队列中,我们担心接收消息的原始顺序。
标签: java jakarta-ee jboss ejb message-driven-bean