批量使用JMS消息 [英] Batch consuming of JMS messages

查看:137
本文介绍了批量使用JMS消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The MessageListener interface only defines a method onMessage that receives a single Message as argument. I'm looking for a way to get multiple Messages from a queue so that I can process the batch and then acknowledge all the Messages in the batch.

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

Is there such feature in JMS world? If no, is it supported by ActiveMQ as an extension?

谢谢,米凯尔

推荐答案

这在

客户端可以使用一个请求来自MessageConsumer的下一条消息 它的接收方法.有几种接收方式 允许客户轮询或等待下一条消息.

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消息确认部分.可能特别有趣的是以下内容:

Note that you should also have a look into acknowledgement when using polling and batch processing - see section 4.4.11 Message Acknowledgment for further information on this. Especially interesting could be the following:

CLIENT_ACKNOWLEDGE-使用此选项,客户端可以确认一条消息 通过调用消息的确认方法.确认消费 消息自动确认收到的所有消息 已在其会话中完成.

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.

这篇关于批量使用JMS消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆