使用Journaled MySQL JDBC Persistence设置ActiveMQ

时间:2011-12-22 13:01:08

标签: mysql persistence activemq

我正在运行ActiveMQ 5.5.1并且遇到了配置日志式JDBC持久性的问题。使用the example here,我收到以下XML验证错误:

./activemq console xbean:my-activemq.xml

Java Runtime: Sun Microsystems Inc. 1.6.0_29 /home/aj/jdk1.6.0_29/jre
  Heap sizes: current=253440k  free=250641k  max=253440k
    JVM args: -Xms256M -Xmx256M -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Dcom.sun.management.jmxremote -Dactivemq.classpath=/home/aj/apache-activemq-5.5.1/conf; -Dactivemq.home=/home/aj/apache-activemq-5.5.1 -Dactivemq.base=/home/aj/apache-activemq-5.5.1
ACTIVEMQ_HOME: /home/aj/apache-activemq-5.5.1
ACTIVEMQ_BASE: /home/aj/apache-activemq-5.5.1
Loading message broker from: xbean:my-activemq.xml

INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@13f3045: startup date [Thu Dec 22 07:49:17 EST 2011]; root of context hierarchy
ERROR: java.lang.RuntimeException: Failed to execute start task.
Reason: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [my-activemq.xml]:
Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type 
'org.apache.activemq.store.journal.JournalPersistenceAdapter' to required type 
'org.apache.activemq.store.PersistenceAdapterFactory' for property 'persistenceFactory'; 
nested exception is java.lang.IllegalStateException: Cannot convert value of type 
[org.apache.activemq.store.journal.JournalPersistenceAdapter] to required type 
[org.apache.activemq.store.PersistenceAdapterFactory] for property 'persistenceFactory': no matching editors or conversion strategy found

我已经审核了the published schema,但它似乎与此示例完全不同,因此很明显两个来源中的一个不同步。任何人都可以使用Journaled JDBC与MySQL共享他们的工作持久性配置吗?

以下是我配置的相关部分:

<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>

  <persistenceFactory>
    <journaledJDBC journalLogFiles="5" dataDirectory="${activemq.base}/activemq-data" dataSource="#mysql-ds"/>
  </persistenceFactory>

1 个答案:

答案 0 :(得分:4)

您可以尝试使用以下配置设置持久性适配器:

<persistenceFactory>
    <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="${activemq.base}/data" dataSource="#mysql-ds">
    </journalPersistenceAdapterFactory>
</persistenceFactory>

它对我有用,但是如果您计划使用故障转移,请注意期刊的缺点 - 它们根本不能一起工作(在奴隶经纪人身上没有您的期刊副本)。经过考虑后,我们决定使用没有日记功能的sql server持久性,它对发布者和订阅者的故障转移都很好。