5.1 ActiveMQ如何存储消息

5.1 How are messages stored by ActiveMQ?

5.1 ActiveMQ如何存储消息

It’s important to gain some basic knowledge of the storage mechanisms for messages

in an ActiveMQ message store. This will aid in configuration and provide an awareness

of what takes place in the ActiveMQ broker during the delivery of persistent messages.

Messages sent to queues and topics are stored differently, because there are some storage

optimizations that can be made with topics that don’t make sense with queues, as

we’ll explain.

了解ActiveMQ消息存储中关于消息存错机制的基础知识相当重要,这有助于理解ActiveMQ消息存储的配置,

有助于了解ActiveMQ代理在消息分发后持久化消息时究竟发生了什么.发送到消息队列和主题中的消息的

存储方式是不同的,因为,正如我们将要讨论的,有一些消息存储方面的优化方案可能适合消息主题中消息存储,

但是不适用于消息队列中消息存储.

Storage for queues is straightforward—messages are basically stored in first in, first

out order (FIFO). See figure 5.1 for a depiction of this. One message is dispatched to a

single consumer at a time. Only when that message has been consumed and acknowledged

can it be deleted from the broker’s message store.

消息队列中消息的存储是简单直接的--这种消息采用先进先出的方式存储.图5.1是这个过程的描述.

一次发送一个消息给单一的消息消费者.当且仅当发送的消息被处理并确认以后,该消息才会从代理的

消息存储中删除.

For durable subscribers to a topic, each consumer gets a copy of the message. In

order to save storage space, only one copy of a message is stored by the broker. A durable

subscriber object in the store maintains a pointer to its next stored message and

dispatches a copy of it to its consumer as shown in figure 5.2. The message store is

implemented in this manner because each durable subscriber could be consuming

messages at different rates or they may not all be running at the same time. Also,

because every message can potentially have many consumers, a message can’t be

deleted from the store until it’s been successfully delivered to every interested durable

subscriber.

对于持久的消息主题订阅者来说,每一个消息消费者会获取一份消息的拷贝.为了节省消息存储空间,

代理只存储一份消息.如图5.2所示,一个持久主题订阅者维护一个指针,该指针指向他订阅的下一条消息,

同时主题订阅者会拷贝这个指针指向的消息然后发送给消息消费者.消息存储设计成这种方式是因为每个持久的

主题订阅者处理消息的速度可能不同,或者它们可能并非同时都在运行.同样,因为一个消息能还用非常到的潜在

消费者,消息不会从存储中删除,除非该消息已经被成功的发送到所有对他感兴趣的持久的消息订阅者.

Every message store implementation for ActiveMQ supports storing messages for

both queues and topics, though obviously the implementation differs between storage

types. For example, the memory store holds all messages in memory.

尽管存储类型明显不同,ActiveMQ的每一种消息存储的实现都支持消息队列中消息和

主题中消息的存储.例如,内存存储中将所有消息都保存在内存中.

Throughout the rest of this chapter, more details about configuring the different

ActiveMQ message stores and their advantages and disadvantages will be explained.

本章的其他章节将阐述各种ActiveMQ消息存储的配置细节以及他们的优缺点.

猜你喜欢

转载自jackyin5918.iteye.com/blog/1958744
5.1
今日推荐