ActiveMQ 持久化配置之Memory Message Store

  ActiveMQ不仅支持persistent和non-persistent两种方式,而其ActiveMQ还支持消息的recovery(恢复)方式。

  消息发送到Queue和Topic的存储原理和结构是不同的,ActiveMQ主要支持以下几种方式:

  · AMQ消息存储-默认的消息存储。

  · KahaDB消息存储-提供了容量的提升和恢复能力。

  · JDBC消息存储-消息基于JDBC存储。

  · Memory消息存储-基于内存的消息存储。

  Memory Message Store

  内存消息存储基于内存(Memory),主要是将所有持久化消息存储在内存中,这里没有动态缓存,所以需要注意当前Broker的JVM内存限制。

  XML配置方式:

<broker brokerName="memory-broker" persistent="false" 		
	xmlns="http://activemq.apache.org/schema/core">
    <transportConnectors>
    	<transportConnector url="tcp://localhost:61615"/>
    </transportConnectors>
</broker>

  编码配置方式:

BrokerService broker = new BrokerService();
broker.setPersistent(false);

broker.addConnector("tcp://localhost:61615");
broker.start();

  Memory Message Store应用场景:

  若在消息体积小、消费过程较快的情况下,可以使用Memory Message Store模式。一般来说,在开发、测试阶段,较为常用。使用Memory Message Store模式时,特别需要注意应用JVM的内存使用情况,以免消息体积过大或消息堆积导致引用宕机。

猜你喜欢

转载自blog.csdn.net/securitit/article/details/106660032
今日推荐