ActiveMQ Artemis和Spring JmsTemplate的性能问题 [英] Performance issues with ActiveMQ Artemis and Spring JmsTemplate

查看:411
本文介绍了ActiveMQ Artemis和Spring JmsTemplate的性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用ActiveMQ Artemis代理和我的Spring Boot应用程序进行一些负载测试时,我遇到了性能问题.

While doing some load tests with the ActiveMQ Artemis broker and my Spring Boot application I am getting into performance issues.

我正在做的是发送例如每秒通过JMSeter向代理发送12,000条消息,应用程序接收到这些消息并将它们保存到DB中.很好但是,当我通过过滤器机制扩展应用程序时,该机制将事件保存到数据库后转发给事件,然后使用jmsTemplate.send(destination, messageCreator)返回给代理,这会非常慢.

What I am doing is, sending e.g. 12,000 messages per second to the broker with JMSeter and the application receives them and saves them to a DB. That works fine. But when I extend my application by a filter mechanism, which forwards events after saving to DB, back to the broker using jmsTemplate.send(destination, messageCreator) it goes very slow.

我首先使用ActiveMQ 5.x,在这里这种机制很好用.您可以在其中配置ActiveMQConnectionFactorysetAsyncSend(true)来调整性能.对于ActiveMQ Artemis ConnectionFactory实现,没有这种可能性.是否有另一种方法可以像ActiveMQ 5.x中那样调整性能?

I first used ActiveMQ 5.x and there this mechanism works fine. There you could configure the ActiveMQConnectionFactory with setAsyncSend(true) to tune performance. For the ActiveMQ Artemis ConnectionFactory implementation there is no such a possibility. Is there another way to tune performance like in ActiveMQ 5.x?

我正在使用Apache ActiveMQ Artemis 2.16.0(但也尝试使用2.15.0),artemis-jms-client 2.6.4和Spring Boot 1.5.16.RELEASE.

I am using Apache ActiveMQ Artemis 2.16.0 (but also tried 2.15.0), artemis-jms-client 2.6.4, and Spring Boot 1.5.16.RELEASE.

推荐答案

要注意的第一件事是,在使用Spring的JmsTemplate发送消息时,您需要非常小心,因为它使用了众所周知的反模式,该模式实际上可以破坏性能.实际上,它将为发送的消息创建一个新的JMS连接,会话和生产者.我建议您使用基于ActiveMQ 5.x连接的此类连接池池实现,但现在支持JMS2.有关使用JmsTemplate的危险的其他详细信息,请参见 ActiveMQ文档.在 Pivotal的文章(即Spring的所有者").

The first thing to note is that you need to be very careful when using Spring's JmsTemplate to send messages as it employs a well-known anti-pattern that can really kill performance. It will actually create a new JMS connection, session, and producer for every message it sends. I recommend you use a connection pool like this one which is based on the ActiveMQ 5.x connection pool implementation but now supports JMS 2. For additional details about the danger of using JmsTemplate see the ActiveMQ documentation. This is also discussed in an article from Pivotal (i.e. the "owners" of Spring).

这里的第二点是 您可以调整是否通过blockOnDurableSend URL属性同步发送持久性JMS消息,例如:

The second point here is that you can tune if persistent JMS messages are sent synchronously or not using the blockOnDurableSend URL property, e.g.:

tcp://localhost:61616?blockOnDurableSend=false

这将确保持久性JMS消息是异步发送的.这将在中进一步讨论. ActiveMQ Artemis文档.

This will ensure that persistent JMS messages are sent asynchronously. This is discussed further in the ActiveMQ Artemis documentation.

这篇关于ActiveMQ Artemis和Spring JmsTemplate的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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