简体   繁体   English

改善ActiveMQ的写入性能

[英]Improving write performance of ActiveMQ

The code at https://github.com/maxant/share/blob/master/DBJMSPerf/src/JMSWriter.java writes BytesMessages to a local ActiveMQ server. https://github.com/maxant/share/blob/master/DBJMSPerf/src/JMSWriter.java上的代码将BytesMessages写入本地ActiveMQ服务器。

I only manage about 200 messages a second (< 5 milliseconds per message). 我每秒只能管理大约200条消息(每条消息<5毫秒)。

Using the code at https://github.com/maxant/share/blob/master/DBJMSPerf/src/DBWriter.java which follows a very similar pattern, I am able to write more than 500 messages a second to a database. 使用https://github.com/maxant/share/blob/master/DBJMSPerf/src/DBWriter.java上的代码遵循非常相似的模式,我能够每秒向数据库写入500条以上的消息。

In both cases, I handle transactions myself, because I want to simulate committing after each message and I re-use the connection since I want to simulate connection pooling. 在这两种情况下,我都自己处理事务,因为我想模拟每条消息之后的提交,并且由于要模拟连接池而重新使用连接。

I use the persistent delivery mode in the JMS example because I am trying to analyse a design which has high availability - messages may not be lost. 我在JMS示例中使用持久交付模式,因为我试图分析具有高可用性的设计-消息可能不会丢失。

At http://activemq.apache.org/performance.html they cite writing messages ten times faster than I am able to. 他们在http://activemq.apache.org/performance.html上引用消息的速度比我快十倍。

How can I improve the performance of the ActiveMQ server? 如何提高ActiveMQ服务器的性能?

You need to use a connection pool to speedup performance as you re-create all the JMS resources per message you send, and that is slow. 在重新创建每条发送的消息的所有JMS资源时,需要使用连接池来提高性能,这很慢。

The JMS based connection pools has very often built-in pooling of session/consumer/producers as well and hence you can keep the code as is. 基于JMS的连接池也经常具有会话/消费者/生产者的内置池,因此您可以按原样保留代码。

Apache ActiveMQ has a pool you can use, and there is also one from the Spring Framework. Apache ActiveMQ有一个可以使用的池,Spring Framework也有一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM