activemq持久化

activemq官方持久化概述:

http://activemq.apache.org/persistence.html


activemq持久化方案: LevelDBKahaDBAMQ Message StoreJDBC databases


一.LevelDB

LevelDB activemq5.8版本引入,它提供了比KahaDB更好的表现,虽然现在未作为默认的消息存储,但被期望实现被作为默认的消息存储的在以后的发型版中。

快速更新

并发读取

使用硬链接的快速索引快照


LevelDB配置:

<broker brokerName="broker" ... >
    ...
    <persistenceAdapter>
      <levelDB directory="activemq-data"/>
    </persistenceAdapter>
    ...
  </broker>

LevelDB属性:

property name default value Comments
directory "LevelDB" The directory which the store will use to hold it's data files. The store will create the directory if it does not already exist.
readThreads 10 The number of concurrent IO read threads to allowed.
sync true If set to false, then the store does not sync logging operations to disk
logSize 104857600 (100 MB) The max size (in bytes) of each data log file before log file rotation occurs.
logWriteBufferSize 4194304 (4 MB) That maximum amount of log data to build up before writing to the file system.
verifyChecksums false Set to true to force checksum verification of all data that is read from the file system.
paranoidChecks false Make the store error out as soon as possible if it detects internal corruption.
indexFactory org.fusesource.leveldbjni.JniDBFactory, org.iq80.leveldb.impl.Iq80DBFactory The factory classes to use when creating the LevelDB indexes
indexMaxOpenFiles 1000 Number of open files that can be used by the index.
indexBlockRestartInterval 16 Number keys between restart points for delta encoding of keys.
indexWriteBufferSize 6291456 (6 MB) Amount of index data to build up in memory before converting to a sorted on-disk file.
indexBlockSize 4096 (4 K) The size of index data packed per block.
indexCacheSize 268435456 (256 MB) The maximum amount of off-heap memory to use to cache index blocks.
indexCompression snappy The type of compression to apply to the index blocks. Can be snappy or none.
logCompression snappy The type of compression to apply to the log records. Can be snappy or none.


二.KahaDB


kahaDB配置:

<broker brokerName="broker" ... >
    <persistenceAdapter>
      <kahaDB directory="activemq-data" journalMaxFileLength="32mb"/>
    </persistenceAdapter>
    ...
</broker>

kahaDB属性:

property name default value Comments
directory activemq-data the path to the directory to use to store the message store data and log files
indexWriteBatchSize 1000 number of indexes written in a batch
indexCacheSize 10000 number of index pages cached in memory
enableIndexWriteAsync false if set, will asynchronously write indexes
journalMaxFileLength 32mb a hint to set the maximum size of the message data logs
enableJournalDiskSyncs true ensure every non transactional journal write is followed by a disk sync (JMS durability requirement)
cleanupInterval 30000 time (ms) before checking for a discarding/moving message data logs that are no longer used
checkpointInterval 5000 time (ms) before checkpointing the journal
ignoreMissingJournalfiles false If enabled, will ignore a missing message log file
checkForCorruptJournalFiles false If enabled, will check for corrupted Journal files on startup and try and recover them
checksumJournalFiles false create a checksum for a journal file - to enable checking for corrupted journals
archiveDataLogs false If enabled, will move a message data log to the archive directory instead of deleting it.
directoryArchive null Define the directory to move data logs to when they all the messages they contain have been consumed.
maxAsyncJobs 10000 the maximum number of asynchronous messages that will be queued awaiting storage (should be the same as the number of concurrent MessageProducers)
concurrentStoreAndDispatchTopics false enable the dispatching of Topic messages to interested clients to happen concurrently with message storage
concurrentStoreAndDispatchQueues true enable the dispatching of Queue messages to interested clients to happen concurrently with message storage
archiveCorruptedIndex false If enabled, corrupted indexes found at startup will be archived (not deleted)


三.AMQ Store


配置:

<broker brokerName="broker" persistent="true" useShutdownHook="false">
    <persistenceAdapter>
      <amqPersistenceAdapter directory="${activemq.base}/activemq-data" maxFileLength="32mb"/>
    </persistenceAdapter>
    <transportConnectors>
      <transportConnector uri="tcp://localhost:61616"/>
    </transportConnectors>
  </broker>

属性:

property name default value Comments
directory activemq-data the path to the directory to use to store the message store data and log files
useNIO true use NIO to write messages to the data logs
syncOnWrite false sync every write to disk
maxFileLength 32mb a hint to 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 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 size of the index key - the key is the message id
indexPageSize 16kb the size of the index page - the bigger the page - the better the write performance of the index
directoryArchive archive the path to the directory to use to store discarded data logs
archiveDataLogs false if true data logs are moved to the archive directory instead of being deleted


四.JDBC database

支持数据库类型:Apache Derby、Axion、DB2、HSQL、Informix、MaxDB、MySQL、Oracle、Postgresql、SQLServer、Sybase

配置:

1.broker中配置持久化

<persistenceAdapter>
     <jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#oracle-ds"/>
</persistenceAdapter>


2.在broker外配置数据源:

<bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
    <property name="username" value="activemq"/>
    <property name="password" value="activemq"/>
    <property name="maxActive" value="200"/>
    <property name="poolPreparedStatements" value="true"/>
</bean>

3. 把相应的驱动放到activemq安装目录的lib目录下,不然会找不到驱动报错。





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值