此内容没有您所选择的语言版本。

Chapter 4. Producer Performance


4.1. Async Sends

Overview

ActiveMQ supports sending messages to a broker in either synchronous or asynchronous mode. The selected mode has a large impact on the latency of the send call: synchronous mode increases latency and can lead to a reduction in the producer's throughput; asynchronous mode generally improves throughput, but it also affects reliability.
Red Hat JBoss A-MQ sends messages in asynchronous mode by default in several cases. It is only in those cases where the JMS specification requires the use of synchronous mode that the producer defaults to synchronous sending. In particular, JMS requires synchronous sends when persistent messages are being sent outside of a transaction.
If you are not using transactions and are sending persistent messages, each send is synchronous and blocks until the broker has sent an acknowledgement back to the producer to confirm that the message is safely persisted to disk. This acknowledgment guarantees that the message will not be lost, but it also has a large latency cost.
Many high performance applications are designed to tolerate a small amount of message loss in failure scenarios. If your application is designed in this fashion, you can enable the use of async sends to increase throughput, even when using persistent messages.

Configuring on a transport URI

To enable async sends at the granularity level of a single producer, set the jms.useAsyncSend option to true on the transport URI that you use to connect to the broker. For example:
tcp://locahost:61616?jms.useAsyncSend=true

Configuring on a connection factory

To enable async sends at the granularity level of a connection factory, set the useAsyncSend property to true directly on the ActiveMQConnectionFactory instance. For example:
// Java
((ActiveMQConnectionFactory)connectionFactory).setUseAsyncSend(true);

Configuring on a connection

To enable async sends at the granularity level of a JMS connection, set the useAsyncSend property to true directly on the ActiveMQConnection instance. For example:
// Java
((ActiveMQConnection)connection).setUseAsyncSend(true);
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.