ACTIVEMQ Message Store Persistence

Source: Internet
Author: User
Tags amq

---------------------------------------------------------------------------------------------------

ACTIVEMQ provides plug-in message storage, mainly in the following ways:

1.AMQ Message Store-file-based storage, which is the previous default message store

2.KahaDB Message store-provides capacity boost and resiliency, and is now the default storage mode

3.JDBC message store-messages are based on JDBC-stored

4.Memory message Store-memory-based message store

The following are described separately:

(1) kahadb Message Store overview
The KAHADB is the default storage method available for any scenario, improving performance and resiliency. The message store uses a transaction log and only an index file to store all of its addresses.
KAHADB is a solution specifically for message persistence, which optimizes typical message usage patterns. In Kaha, the data is appended to the logs. When the data in the log file is no longer needed, the log file is discarded.
KAHADB basic configuration is as follows:

the available properties are:
1. Director:kahadb stored path, default value Activemq-data
2. Indexwritebatchsize: Number of indexed page volumes written to disk, default value is
3. Indexcachesize: Number of In-memory Cache index page, default value 10000
4. Enableindexwriteasync: Whether to asynchronously write out the index, default false
5. Journalmaxfilelength: Set the size of each message data log, default is 32MB
6. Enablejournaldisksyncs: Set whether to ensure that each non-transactional content, is synchronously written to disk, JMS persistence required, the default is True
7. CleanupInterval: After checking for messages that are no longer in use, the time before the specific deletion of the message, the default 30000
8. Checkpointinterval:checkpoint interval, the default is
9. Ignoremissingjournalfiles: Ignore missing message log file, default false
checkforcorruptjournalfiles: At boot time, the message file will be verified for corruption, default false
Checksumjournalfiles: Whether to provide checksum for each message log file, default false
Archivedatalogs: Whether to move files to a specific path instead of deleting them, default false
directoryarchive: Defines the path to which data log is moved after the message has been consumed, default null
Databaselockedwaitdelay: The wait time to obtain a database lock (used by shared Master/slave), the default 10000
maxasyncjobs: Sets the maximum number of asynchronous message queues that can be stored, with a default value of 10000, which can be set to the same value as the concurrent messageproducers.
concurrentstoreanddispatchtransactions: Whether to distribute the message to the client while the transaction stores the message by default true
Concurrentstoreanddispatchtopics: Whether to distribute topic messages to the client while storing them, by default true
Concurrentstoreanddispatchqueues: Whether the queue message is distributed to the client while it is stored, by default True

(2) AMQ Message Store Overview

The AMQ message store is the ActiveMQ5.0 default persistent store, which is a file-based, transaction-store-designed structure for fast message storage that interacts with the message in the form of a stream.
In this way, messages is saved to data logs and is indexed by the reference store to improve access speed. Data logs consists of a few simple data log files, the default file size is 32M, if a message is larger than the size of the data log file, you can modify the configuration to increase the size of the data log file. If all the messages in a data log file are consumed successfully, the data log file will be flagged for deletion or archival in the next round of cleanup.
AMQ Message Store Configuration Example:

(3) using JDBC to persist messages

ACTIVEMQ supports using JDBC to persist messages, and the predefined tables are as follows:
1. The message table, which is indicated by default as ACTIVEMQ_MSGS, Queue and topic, are stored inside the structure as follows:

The 2.activemq_acks table stores information about the persistent subscription and the message ID received by the last durable subscription, as follows:

3. Lock the table, the default table name is Activemq_lock, to ensure that at some point, there can only be one ACTIVEMQ broker instance to access the database, the structure is as follows:

Example of a configuration that uses JDBC to persist messages:
The configuration in Activemq.xml is as follows:

1<broker brokername= "Test-broker" persistent=truexmlns= "Http://activemq.apache.org/schema/core" >2<persistenceAdapter>3<jdbcpersistenceadapter datasource= "#mysql_ds" >4</persistenceAdapter>5</broker>6<bean name= "Mysql_ds"class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" >7<property name= "Driverclassname" >8<value>org.gjt.mm.mysql.Driver</value>9</property>Ten<property name= "url" > One<value>jdbc:mysql://192.168.1.102:3306/test?useunicode=true&amp;characterencoding=utf-8</value> A</property> -<property name= "username" > -<value>root</value> the</property> -<property name= "Password" > -<value>123123</value> -</property> +</bean>

JDBC Message Store with ActiveMQ Journal
This approach overcomes the lack of the JDBC store and uses fast cache write technology to improve performance significantly.
The configuration is as follows:

1 <beans>2 <broker brokername= "Test-broker" xmlns= "http://activemq.apache.org/schema/  Core ">3 <persistenceFactory>4 <journalpersistenceadapterfactory journallogfiles=" 4 " Journallogfilesize= "32768"5 usejournal= "true" usequickjournal= "true" datasource= "#mysql_ds" dataDirectory = "Activemq-data" >6 </persistenceFactory>7 </broker>8 </beans>

JDBC Store and JDBC Message store with ActiveMQ Journal difference :
1. The performance of the JDBC with Journal is better than the JDBC
2. JDBC Database for Master/slave mode sharing
3. JDBC with journal cannot be used in Master/slave mode
4. In general, JDBC is recommended With journal
(4) Memory Message Store
The memory message store is primarily a store of all persisted messages in memory. There is no dynamic cache present, so you must be careful to set the JVM and memory limits where your broker resides.

1 <beans>2 <broker brokername= "Test_broker" persistent= "false" xmlns= "HTTP// Activemq.apache.org/schema/core ">3 <transportConnectors>4 <transportconnector uri=" tcp://localhost:61635 ">5 </transportConnectors>6 </beans>

ACTIVEMQ Message Store Persistence

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.