ActiveMQ 的 prefetch-limit
1.官方文档
http://activemq.apache.org/what-is-the-prefetch-limit-for.html
One of the aims of ActiveMQ is to be a high performance message bus. This means
using a SEDA(http://activemq.apache.org/seda.html) architecture to perform as
much work as possible asynchronously. To be able to achieve high performance
it is important to stream messages to consumers as fast as possible so
that the consumer always has a buffer of messages, in RAM, ready to
process - rather than have them explicitly pull messages from the server
which adds significant latency per message.
ActiveMQ的一个目标是成为高性能消息总线.这就是说,ActiveMQ采用SEDA结构以异步方式尽可能
高效的处理更多工作.为了获取高性能,ActiveMQ必须尽可能快的将消息传送给消费者以便消费者
可以使用RAM消息缓存,而不是让消费者主动从代理服务器一个一个地拉取消息,因为这样会为每个
消息增加大量的延迟.
There is a danger however that this aggressive pushing of messages to the
consumers could flood a consumer as typically its much faster to deliver
messages to the consumer than it often is to actually process them.
这种侵入式的推送消息给消费者的行为是危险的,因为可能导致消费者被大量消息淹没.毕竟,通常
发送消息给消费者要比消费者处理消息快的多.
So ActiveMQ uses a prefetch limit on how many messages can be streamed to a
consumer at any point in time. Once the prefetch limit is reached, no more
messages are dispatched to the consumer until the consumer starts sending back
acknowledgements of messages (to indicate that the message has been processed).
The actual prefetch limit value can be specified on a per consumer basis.
因此,ActiveMQ使用prefetch limit限制任何时候消息消费者已接受到但尚未完成处理的消息数量.
一旦消息数量达到prefetch limit限制,则在消费者开始发送消息确认(指示消息已经被处理了)之前
不会再发送任何消息给消费者.可以为每一个消息消费者单独设置prefetch limit 值.
Its a good idea to have large values of the prefetch limit if you want high
performance and if you have high message volumes. If you have very few messages
and each message takes a very long time to process you might want to set the
prefetch value to 1 so that a consumer is given one message at a time.
Specifying a prefetch limit of zero means the consumer will poll for more
messages, one at a time, instead of the message being pushed to the consumer.
如果你打算高效的发送大量消息,那么为prefetch limit设置一个比较大的值是一个不错的注意.
如果你只打算发送很少的消息,并且每一个消息的处理时间很长,那么可以设置prefetch limit值
为1,这样消息者每次只会接收到一个消息.设置prefetch limit 值为0表示,消费者每次主动拉取更
多消息,而不是由代理推送消息到消费者.
Specifying the PrefetchPolicy
配置 prefetch limit
You can specify an instance of the ActiveMQPrefetchPolicy on an
ActiveMQConnectionFactory or ActiveMQConnection. This allows you to configure
all the individual prefetch values; as each different quality of service has a
different value. e.g.
persistent queues (default value: 1000)
non-persistent queues (default value: 1000)
persistent topics (default value: 100)
non-persistent topics (default value: Short.MAX_VALUE -1)
It can also be configured on the connection URI used when establishing a connection the broker:
To change the prefetch size for all consumer types you would use a connection URI similar to:
tcp://localhost:61616?jms.prefetchPolicy.all=50
To change the prefetch size for just queue consumer types you would use a connection URI similar to:
tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1
It can also be configured on a per consumer basis using Destination Options.
queue = new ActiveMQQueue("TEST.QUEUE?consumer.prefetchSize=10");
consumer = session.createConsumer(queue);
相关推荐
《ActiveMQ-CPP Library 3.9.5在Windows环境下的编译与应用》 ActiveMQ-CPP Library 3.9.5是一款专为C++开发者设计的、用于与Apache ActiveMQ集成的库,它提供了丰富的API接口,使得在C++环境中能够方便地发送和...
《ActiveMQ-CPP库3.9.5源代码解析与应用》 ActiveMQ-CPP库是Apache ActiveMQ项目的一部分,它提供了一套C++接口,用于与ActiveMQ消息代理进行通信。这个库允许开发者在C++应用程序中实现高级消息队列协议(AMQP)和...
赠送jar包:activemq-protobuf-1.1.jar; 赠送原API文档:activemq-protobuf-1.1-javadoc.jar; 赠送源代码:activemq-protobuf-1.1-sources.jar; 包含翻译后的API文档:activemq-protobuf-1.1-javadoc-API文档-...
activemqBroker插件:activemqBroker-2.14-SNAPSHOT.war
赠送jar包:activemq-core-5.7.0.jar; 赠送原API文档:activemq-core-5.7.0-javadoc.jar; 赠送源代码:activemq-core-5.7.0-sources.jar; 包含翻译后的API文档:activemq-core-5.7.0-javadoc-API文档-中文...
这个“apache-activemq-5.9.0-bin”压缩包包含了Apache ActiveMQ 5.9.0版本的完整二进制文件,用于在本地或网络环境中安装和运行。 Apache ActiveMQ的核心功能包括: 1. **消息队列**:ActiveMQ支持多种消息模式,...
activemq-parent-5.10.0-source-release.zip activemq-parent-5.10.2-source-release.zip activemq-parent-5.12.3-source-release.zip apache-activemq-5.10.2-bin.tar.gz apache-activemq-5.11.4-bin.zip apache-...
activemq-all-5.2.0.JAR包,欢迎下载。编写java中间件的时候会用到。这是activemq实现的jms中间件。希望能帮助到你。
activemq-web-console的默认使用方式是通过在activemq.xml中导入jetty.xml配置一个jetty server来实现的。其实activemq-web-console完全可以和activemq-broker分开来部署。 activemq-web-console包含3个apps, 1.一...
这个压缩包"apache-activemq-5.8.0-bin.zip"包含了ActiveMQ 5.8.0版本的二进制发行版,供用户在本地计算机上安装和运行。 1. **Apache ActiveMQ简介** - Apache ActiveMQ是业界广泛使用的消息代理,提供可靠的消息...
这个"apache-activemq-5.15.8-bin.zip"文件包含了ActiveMQ的可执行版本,用于在本地计算机上安装和运行ActiveMQ服务。 首先,我们需要了解ActiveMQ的核心概念。它是一个消息代理,扮演着消息生产者与消费者之间的...
activemq-all-5.6.0.jar activemq-all-5.6.0.jar activemq-all-5.6.0.jar activemq-all-5.6.0.jar
activemq-protobuf-1.1.jar;activemq-protobuf-1.1.jar
activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载 activemq-all-5.8.0.jar 下载
activemq5.15.0-1 jar
这个`apache-activemq-5.13.2-bin.tar.gz`压缩包包含了ActiveMQ的可执行版本,适用于运行在Linux环境下的Java应用程序。版本号5.13.2意味着这是该软件的特定稳定版本,它可能包含了bug修复和性能优化。 ActiveMQ的...
这个"apache-activemq-5.14.3-bin.zip"压缩包包含了在Windows环境下部署和运行ActiveMQ所需的所有文件。让我们深入探讨一下这个版本的ActiveMQ及其在Java消息服务中的应用。 首先,Java消息服务(JMS)是一种标准...
标签:activemq-kahadb-store-5.9.1.jar,activemq,kahadb,store,5.9.1,jar包下载,依赖包
MQ是消息中间件,是一种在分布式系统中应用程序借以传递消息的媒介,常用的有ActiveMQ,RabbitMQ,kafka。ActiveMQ是Apache下的开源项目,完全支持JMS1.1和J2EE1.4规范的JMS Provider实现。 特点: 1、支持多种...
在“apache-activemq-5.12.0-bin”这个压缩包中,包含了运行Apache ActiveMQ所需的所有文件,适用于Windows操作系统。 Apache ActiveMQ作为消息队列的实现,主要功能包括: 1. **消息传输**:ActiveMQ允许应用程序...