`
whitesock
  • 浏览: 481998 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

ActiveMQ in Action (3)

    博客分类:
  • EE
阅读更多

2.3 Persistence
2.3.1 AMQ Message Store
    AMQ Message Store是ActiveMQ5.0 缺省的持久化存储。Message commands被保存到transactional journal(由rolling data logs组成)。Messages被保存到data logs中,同时被reference store进行索引以提高存取速度。Date logs由一些单独的data log文件组成,缺省的文件大小是32M,如果某个消息的大小超过了data log文件的大小,那么可以修改配置以增加data log文件的大小。如果某个data log文件中所有的消息都被成功消费了,那么这个data log文件将会被标记,以便在下一轮的清理中被删除或者归档。以下是其配置的一个例子:

<broker brokerName="broker" persistent="true" useShutdownHook="false">
  <persistenceAdapter>
     <amqPersistenceAdapter directory="${activemq.base}/data" maxFileLength="32mb"/>
  </persistenceAdapter>
</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

 

2.3.2 Kaha Persistence
    Kaha Persistence 是一个专门针对消息持久化的解决方案。它对典型的消息使用模式进行了优化。在Kaha中,数据被追加到data logs中。当不再需要log文件中的数据的时候,log文件会被丢弃。以下是其配置的一个例子:

<broker brokerName="broker" persistent="true" useShutdownHook="false">
      <persistenceAdapter>
        <kahaPersistenceAdapter directory="activemq-data" maxDataFileLength="33554432"/>
      </persistenceAdapter>
</broker>

 

2.3.3 JDBC Persistence
    目前支持的数据库有Apache Derby, Axion, DB2, HSQL, Informix, MaxDB, MySQL, Oracle, Postgresql, SQLServer, Sybase。
    如果你使用的数据库不被支持,那么可以调整StatementProvider 来保证使用正确的SQL方言(flavour of SQL)。通常绝大多数数据库支持以下adaptor:

  • org.activemq.store.jdbc.adapter.BlobJDBCAdapter
  • org.activemq.store.jdbc.adapter.BytesJDBCAdapter
  • org.activemq.store.jdbc.adapter.DefaultJDBCAdapter
  • org.activemq.store.jdbc.adapter.ImageJDBCAdapter

   也可以在配置文件中直接指定JDBC adaptor,例如:

<jdbcPersistenceAdapter  adapterClass="org.apache.activemq.store.jdbc.adapter.ImageBasedJDBCAdaptor"/>

    以下是其配置的一个例子:

 

<persistence>
      <jdbcPersistence dataSourceRef=" mysql-ds"/>
</persistence>

<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="poolPreparedStatements" value="true"/>
</bean>

    需要注意的是,如果使用MySQL,那么需要设置relaxAutoCommit 标志为true。

 

2.3.4 Disable Persistence
    以下是其配置的一个例子:

<broker persistent="false">
</broker> 
15
1
分享到:
评论
3 楼 jd2bs 2010-07-13  
activeMQ5.3.2里 貌似已经默认用KahaDB来持久化Message
2 楼 whitesock 2008-11-12  
此问题应该是和ActiveMQ无关,如果用mysql, 那么修改max_allowed_packet参数(例如max_allowed_packet=32M)。
1 楼 wwm4851186 2008-11-10  
把activemq的信息保存到数据库中,ACTIVEMQ_MSGS这个表的MSG字段只能保存几K的数据,十几K的数据就出现数据太大的提示,插不进去,有没有遇到过这样的情况

相关推荐

    ActiveMQ in Action pdf英文版+源代码

    ActiveMQ in Action pdf英文原版加源代码压缩包。 Apache ActiveMQ in Action is a thorough, practical guide to implementing message-oriented systems in Java using ActiveMQ. The book lays out the core of ...

    ActiveMQ In Action及其源码

    《ActiveMQ In Action》是一本深入探讨Apache ActiveMQ的权威指南,这本书主要涵盖了消息中间件在实际应用中的各种场景和解决方案。ActiveMQ是Apache软件基金会开发的一个开源消息代理,它支持多种消息协议,如...

    ActiveMQ in Action

    根据书籍提供的简介,读者可以预期从《ActiveMQ in Action》中获得从安装和配置到深入开发的全面指导,包括连接到ActiveMQ、消息存储、安全性配置以及构建使用ActiveMQ的应用程序的案例。书籍同样着重介绍了如何利用...

    《ActiveMQ in Action》2010版

    《ActiveMQ in Action》2010版是Manning Publications在2009年发布的一本关于Apache ActiveMQ的专业书籍,旨在深入介绍消息中间件和Java消息服务(JMS)的概念,以及如何有效地使用ActiveMQ。书中包含了第7、9、11、...

    activemq in action PDF 英文版 源代码 合二为一

    《ActiveMQ in Action》是一本深入探讨Apache ActiveMQ的专著,由Michael Burman和Peter Monks撰写。这本书详尽地介绍了如何使用ActiveMQ这一强大的开源消息代理来构建高效、可扩展和可靠的分布式应用程序。英文版是...

    ActiveMQ in action.pdf 英文版

    《ActiveMQ in Action》是一本深受读者欢迎的关于Apache ActiveMQ的权威指南,它深入浅出地介绍了如何在实际环境中运用这一开源消息中间件。ActiveMQ是Java消息服务(JMS)的一个实现,广泛用于分布式系统中的异步...

    ActiveMQ in Action 无水印pdf

    ActiveMQ in Action 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    ActiveMQ in Action最新版

    ActiveMQ 不仅实现了 JMS 规范中定义的所有特性,也额外提供了一些特有且有用的特性。我们会在 3.1 小节详细列说这些特性,并且书中剩余的章节还会继续讨论这些特性。为了演示这些特性,我们创建了两个基于实际业务...

    activemq in action.pdf

    以上概述了《ActiveMQ In Action》这本书的主要知识点,涵盖了从基础知识到实践案例再到高级配置等各个方面。通过学习这些内容,开发者可以深入了解ActiveMQ的工作原理,并能够灵活地将其应用于各种业务场景中。

    ActiveMQ In Action翻译笔记-更新版2011

    ### ActiveMQ In Action翻译笔记-更新版2011 关键知识点详解 #### 一、ActiveMQ概述 **ActiveMQ**是Apache旗下的一款开源、高性能、功能丰富的消息中间件,支持多种消息传递模式,包括点对点(PTP)和发布/订阅...

    activeMq in action 使用activeMq开发JMS的简单讲述

    3. **多种协议**:除了JMS之外,ActiveMQ还支持STOMP、AMQP、MQTT等多种消息传输协议,增加了系统的兼容性。 4. **高可用性**:通过网络集群和故障转移,ActiveMQ可以实现高可用性和负载均衡,确保服务不间断。 5. *...

    ActiveMQ In Action精简版

    根据给定的文件信息,以下是从“ActiveMQ In Action精简版”中提炼出的关键IT知识点,主要聚焦于ActiveMQ的介绍、配置、使用及高级功能。 ### ActiveMQ概述 ActiveMQ是Apache软件基金会下的一个开源项目,它是一款...

    activeMQ in action 2011

    《ActiveMQ in Action 2011》是2011年出版的一本关于Apache ActiveMQ的权威指南,由行业专家撰写,旨在帮助读者深入理解并有效地使用这一强大的消息中间件。ActiveMQ是Apache软件基金会的一个开源项目,它提供了一个...

    ActiveMQ_in_Action_中文.zip

    《ActiveMQ in Action》中文版是一个关于Apache ActiveMQ的详细指南,这是一款广泛使用的开源消息代理,也是Java消息服务(JMS)实现的领先者。这本书深入探讨了ActiveMQ的各个方面,包括其核心功能、使用场景以及...

    ActiveMQ in Action 中文

    ActiveMQ in Action是一本介绍ActiveMQ的书籍,虽然作者未知,但它是对ActiveMQ入门到一般管理非常有帮助的中文资料。该书在英文原版基础上增加了书签功能,方便读者阅读。书中首先介绍了JMS(Java消息服务)规范,...

    ActiveMQ in Action.rar

    《ActiveMQ in Action》这本书是了解和掌握Apache ActiveMQ这一开源消息代理的宝贵资源。ActiveMQ是Apache软件基金会开发的一款企业级的消息中间件,广泛应用于分布式系统中的消息传递和解耦。通过深入阅读这本书,...

    ActiveMQ In Action.zip

    《ActiveMQ In Action》这本书是了解和掌握Apache ActiveMQ这一开源消息中间件的绝佳资源。ActiveMQ是Apache软件基金会开发的一款高效、灵活且可靠的开源消息代理,它支持多种消息协议,如OpenWire、AMQP、STOMP等,...

Global site tag (gtag.js) - Google Analytics