The Basics

This is the default storage for AcitveMQ 5 và above. The AMQ Message Store is an embeddable transactional message storage solution that is extremely fast và reliable.message commands are written to a transactional journal - which consists of rolling data logs - which means writing is extremely fast and the state of the store is easily recoverable.

Bạn đang xem: Amq

Messages themselves are persisted in the data logs of the journal - with references to lớn their location being held by a reference store (by mặc định Kaha) for fast retrevial.


References to messages are held in memory, và periodically inserted into the reference store to lớn improve performance.

The messages are stored in data logs, which are individual files, typically 32mb in form size (though this is configurable, they can be larger if the form size of a message is large than the tệp tin size). When all the messages in a data log have been successfully consumed, the data log tệp tin is marked as being ready lớn be deleted - or archived - which will happen at the next clean up period.


By mặc định will use the the AMQ Store - and its mặc định settings. You can configure the properties of the AMQ Store however, by explictly defining its persistence adapter (amqPersistenceAdapter):

The above shows the configuration required khổng lồ set the AMQ Store through its amqPersistenceAdapter - and explicity setting the directory và maxFileLength properties.

AMQ Store Properties

property name mặc định value Comments
directory the path to the directory khổng lồ use lớn store the message store data & log files
useNIO true use NIO to lớn write messages to lớn the data logs
syncOnWrite false sync every write lớn disk
maxFileLength 32mb a hint to lớn set the maximum size of the message data logs
persistentIndex true use a persistent index for the message logs. If this is false, an in-memory structure is maintained
maxCheckpointMessageAddSize 4kb the maximum number of messages to lớn keep in a transaction before automatically committing
cleanupInterval 30000 time (ms) before checking for a discarding/moving message data logs that are no longer used
indexBinSize 1024 default number of bins used by the index. The bigger the bin size - the better the relative performance of the index
indexKeySize 96 the kích cỡ of the index key - the key is the message id
indexPageSize 16kb the kích cỡ of the index page - the bigger the page - the better the write performance of the index
directoryArchive archive the path to the directory khổng lồ use to lớn store discarded data logs
archiveDataLogs false if true data logs are moved to the archive directory instead of being deleted

Data Structure

In the data directory defined for the AMQ Store there is the following directory structure:


Top level

the message broker’s name is used to lớn distinguish its directory of message data. By default, the broker name is local host.Below this top màn chơi directory are the following sub directories:


message data logs are moved here when they are discarded.n.b. This directory only exists when the property archiveDataLogs is enabled


Used to lớn hold the message data logs


The directory structure of the Kaha reference store (if used)


The indexes used to lớn reference the message data logs in the journal for fast retrieval


The state of the store - i.e. Names of durable subscribers - the reason for this is described in Recovery


use khổng lồ hold data files for transient messages that may be stored on disk to lớn alleviate memory consumption - e.g. Non-persistent topic messages awaiting delivery lớn an active, but slow subscriber.

Xem thêm: Tập Làm Văn Lớp 3 Viết Thư Cho Bạn, Viết Thư Cho Một Người Bạn Để Làm Quen Hay Nhất


If the message broker does not shutdown properly, then the reference store indexes are cleaned và the message data files (which contain messages/acknowledgements và transactional boundaries) are replayed lớn rebuild up the message store state. It is possbile khổng lồ force automatic recovery if using the Kaha reference store (the default) by deleting the kr-store/state/ directory.