5 ActiveMQ 消息存储

ActiveMQ message storage

ActiveMQ 消息存储

This chapter covers

 How messages are stored in ActiveMQ for both queues and topics

 The four styles of message stores provided with ActiveMQ

 How ActiveMQ caches messages for consumers

 How to control message caching using subscription recovery policies

本章内容包括:

    ActiveMQ中消息对立和主题中的消息是如何存储的

    ActiveMQ提供的四种消息存储方式

    ActiveMQ如何为消息消费者缓存消息

    如何使用指定的恢复策略控制消息缓存

The JMS specification supports two types of message delivery: persistent and nonpersistent.

A message delivered with the persistent delivery property must be

logged to stable storage. For nonpersistent messages, a JMS provider must make

best efforts to deliver the message, but it won’t be logged to stable storage.

JMS规范支持两种方式分发消息:持久化和非持久化.以持久化方式分发的消息必须进行持久化存储.

对于非持久化的消息,JMS提供者必须保证尽最大努力分发消息,但消息不会进行持久化存储.

ActiveMQ supports both of these types of message delivery and can also be configured

to support message recovery, an in-between state where messages are

cached in memory. ActiveMQ supports a pluggable strategy for message storage and

provides storage options for in-memory, file-based, and relational databases.

ActiveMQ同时支持上面两种方式的消息分发.另外通过配置可以支持消息的恢复--一种缓存在内存中的

中间状态的消息.ActiveMQ支持一种可插拔式的消息存储,并且提供三种方式消息存储:存储到内存,

存储到文件,以及存储到相关的数据库.

Persistent messages are used if you want messages to always be available to a

message consumer after they’ve been delivered to the broker, even if that consumer

isn’t running when the message was sent. Once a message has been

consumed and acknowledged by a message consumer, it’s typically deleted from the

broker’s message store.

持久化消息被发送到代理后总是可用的,即便消息发送时消息消费者不在运行.一旦消息被处理并

被消息消费者确认后,消息将会从代理的消息存储中删除.

Nonpersistent messages are typically used for sending notifications or real-time

data. You should use nonpersistent messages when performance is critical and guaranteed

delivery of the message isn’t required.

非持久化消息常用语发送通知或者实时数据.当系统十分注重性能并且不用保证消息正常分发时

你应该使用非持久化消息.

This chapter will first examine why messages are stored differently for queues and

topics. We’ll then look at all four different message stores available to ActiveMQ, and

why and when to use them for your application. Finally we’ll look at how ActiveMQ

can be configured to temporarily cache messages for retrieval by message consumers

at a later point in time. The flexibility offered by ActiveMQ for caching messages is

unique, allowing fine control of message retrieval for your application.

本章内容首先说明为什么消息要通过队列和主题两种方式存储.我们还将看到ActiveMQ的四种消息存储方式

以及什么情况下和为什么要在应用程序中使用这四种消息存储方式.最后,我们将看到ActiveMQ如何配置临时

消息缓存以便消息消费者能够在消息发送后的某个时间及时的重新接收消息.ActiveMQ提供的这种灵活的消息

缓存方式是独一无二的,允许你在应用程序中完美的控制消息的接收.

This chapter will provide a detailed guide to message persistence. In order to lay the

groundwork for this, first we’ll examine the storage of messages for JMS destinations.

本章将提供消息持久化的详细指导.为了打好基础,本章中我们首先说明JMS目的地的消息存储.

猜你喜欢

转载自jackyin5918.iteye.com/blog/1958702