Message persistence allows for the recovery of undelivered messages in the event of a system failure. By default, ActiveMQ's persistence features are activated. The default set-up is fast and scalable. It is easy to customize the broker configuration to use a JDBC compliant database.
Loss of messages is not acceptable in mission critical applications. ActiveMQ reduces the risk of message loss by using a persistent message store by default. Persistent messages are written to the persistent store when they are sent. The messages persist in the store until their delivery is confirmed. This means that, in the case of a system failure, ActiveMQ can recover all of the undelivered messages at the time of the failure.
The default message store is embeddable and transactional. It is both very fast and extremely reliable. ActiveMQ implements several different kinds of message store, including:
KahaDB message store.
Journaled JDBC adapter.
Non-journaled JDBC adapter.
![]() | Note |
|---|---|
The preceding persistence adapters are the most important ones. Some of the ActiveMQ persistence adapters—that is, the AMQ message store and the (original) Kaha persistence adapter—represent ealier versions of the built-in message store. They are kept for backward compatibiliby reasons, but are superseded by the KahaDB message store. |
Persistence in ActiveMQ is controlled by a broker's XML configuration file. To change a
broker's persistence behavior you modify the configuration's broker
element's persistent attribute.
Table 1.1. Setting a Broker's Persistence
| Value | Description |
|---|---|
true | The broker will use message persistence. |
false | The broker will not use message persistence. If you add a persistence adapter to the broker's configuration, the adapter will be ignored. |
![]() | Tip |
|---|---|
By default, a broker's |
Example 1.1 shows a configuration snippet for turning off a broker's message persistence.
ActiveMQ offers a number of different persistence mechanisms besides the default message
store. To use one of the alternative message stores, or to modify the default behavior of the
default message store, you need to configure the persistence adapter. This is done by adding a
persistenceAdapter element or a persistenceFactory element
(depending on the kind of adapter you want to use) to the broker's configuration
file.