gpt4 book ai didi

java - 批量消费JMS消息

转载 作者:搜寻专家 更新时间:2023-11-01 02:22:36 26 4
gpt4 key购买 nike

MessageListener 接口(interface)只定义了一个方法 onMessage 接收单个 Message 作为参数。我正在寻找一种从队列中获取多个 Message 的方法,以便我可以处理该批处理,然后确认该批处理中的所有 Message

JMS世界有这样的功能吗?如果不是,ActiveMQ 是否支持它作为扩展?

谢谢,迈克尔

最佳答案

这在 JMS 1.1 spec 中有解释4.5.1 同步交付部分:

A client can request the next message from a MessageConsumer using one of its receive methods. There are several variations of receive that allow a client to poll or wait for the next message.

9.2.2 同步接收消息部分甚至有一个代码示例:

TextMessage stockMessage;
stockMessage = (TextMessage)receiver.receive();

请注意,在使用轮询和批处理时,您还应该查看确认 - 有关这方面的更多信息,请参阅4.4.11 消息确认部分。以下内容可能特别有趣:

CLIENT_ACKNOWLEDGE - With this option, a client acknowledges a message by calling the message’s acknowledge method. Acknowledging a consumed message automatically acknowledges the receipt of all messages that have been delivered by its session.

关于java - 批量消费JMS消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35742002/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com