【问题标题】:Configure ActiveMQ with MySQL使用 MySQL 配置 ActiveMQ
【发布时间】:2012-06-01 15:25:47
【问题描述】:

我需要使用 MySQL 设置 ActiveMQ,我遵循这篇文章 http://note19.com/2007/06/23/configure-activemq-with-mysql/

我发现如果我有以下配置。 MQ 无法启动

 <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="xxxx"/>
    <property name="password" value="xxxx"/>
    <property name="poolPreparedStatements" value="true"/>
  </bean>

下面是错误

2012-05-25 18:40:46,565 |错误 |加载失败:类路径资源 [activemq.xml],原因:来自类路径的 XML 文档中的第 109 行 资源 [activemq.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException;行号:109;列号:40; cvc-complex-type.2.4.a:发现无效内容以 元素“豆”。之一 '{"http://activemq.apache.org/schema/core":adminView, "http://activemq.apache.org/schema/core":brokerContext, "http://activemq.apache.org/schema/core":consumerSystemUsage, "http://activemq.apache.org/schema/core":destinationFactory, "http://activemq.apache.org/schema/core":destinationInterceptors, "http://activemq.apache.org/schema/core":destinationPolicy, “http://activemq.apache.org/schema/core”:目的地, "http://activemq.apache.org/schema/core":ioExceptionHandler, "http://activemq.apache.org/schema/core":jmsBridgeConnectors, "http://activemq.apache.org/schema/core":managementContext, "http://activemq.apache.org/schema/core":messageAuthorizationPolicy, "http://activemq.apache.org/schema/core":networkConnectorURIs, "http://activemq.apache.org/schema/core":networkConnectors, "http://activemq.apache.org/schema/core":persistenceAdapter, "http://activemq.apache.org/schema/core":persistenceFactory, "http://activemq.apache.org/schema/core":persistenceTaskRunnerFactory, “http://activemq.apache.org/schema/core”:插件, "http://activemq.apache.org/schema/core":producerSystemUsage, "http://activemq.apache.org/schema/core":proxyConnectors, "http://activemq.apache.org/schema/core":regionBroker, “http://activemq.apache.org/schema/core”:服务, "http://activemq.apache.org/schema/core":shutdownHooks, "http://activemq.apache.org/schema/core":sslContext, "http://activemq.apache.org/schema/core":systemUsage, "http://activemq.apache.org/schema/core":taskRunnerFactory, "http://activemq.apache.org/schema/core":tempDataStore, "http://activemq.apache.org/schema/core":transportConnectorURIs, "http://activemq.apache.org/schema/core":transportConnectors, WC[##other:"http://activemq.apache.org/schema/core"]}' 是预期的。 | org.apache.activemq.xbean.XBeanBrokerFactory |主要的 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 来自类路径资源 [activemq.xml] 的 XML 文档中的第 109 行是 无效的;嵌套异常是 org.xml.sax.SAXParseException; 行号:109;列号:40; cvc-complex-type.2.4.a:无效 发现内容以元素“bean”开头。之一 '{"http://activemq.apache.org/schema/core":adminView, "http://activemq.apache.org/schema/core":brokerContext, "http://activemq.apache.org/schema/core":consumerSystemUsage, "http://activemq.apache.org/schema/core":destinationFactory, "http://activemq.apache.org/schema/core":destinationInterceptors, "http://activemq.apache.org/schema/core":destinationPolicy, “http://activemq.apache.org/schema/core”:目的地, "http://activemq.apache.org/schema/core":ioExceptionHandler, "http://activemq.apache.org/schema/core":jmsBridgeConnectors, "http://activemq.apache.org/schema/core":managementContext, "http://activemq.apache.org/schema/core":messageAuthorizationPolicy, "http://activemq.apache.org/schema/core":networkConnectorURIs, "http://activemq.apache.org/schema/core":networkConnectors, "http://activemq.apache.org/schema/core":persistenceAdapter, "http://activemq.apache.org/schema/core":persistenceFactory, "http://activemq.apache.org/schema/core":persistenceTaskRunnerFactory, “http://activemq.apache.org/schema/core”:插件, "http://activemq.apache.org/schema/core":producerSystemUsage, "http://activemq.apache.org/schema/core":proxyConnectors, "http://activemq.apache.org/schema/core":regionBroker, “http://activemq.apache.org/schema/core”:服务, "http://activemq.apache.org/schema/core":shutdownHooks, "http://activemq.apache.org/schema/core":sslContext, "http://activemq.apache.org/schema/core":systemUsage, "http://activemq.apache.org/schema/core":taskRunnerFactory, "http://activemq.apache.org/schema/core":tempDataStore, "http://activemq.apache.org/schema/core":transportConnectorURIs, "http://activemq.apache.org/schema/core":transportConnectors, WC[##other:"http://activemq.apache.org/schema/core"]}' 是预期的。

参考:

  1. mysql Ver 14.14 Distrib 5.5.22,适用于使用 readline 6.2 的 debian-linux-gnu (x86_64)
  2. activemq 版本 5.6.0

【问题讨论】:

    标签: mysql activemq


    【解决方案1】:

    我猜你是在代理标签中提供定义。请在代理之外创建数据源 bean。请参考这个link

    【讨论】:

      【解决方案2】:

      引用博客上的示例已过时。持久化元素应该定义为:

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

      这应该可以解决问题。

      问候, 斯科特 ES

      【讨论】:

        猜你喜欢
        • 2015-07-27
        • 1970-01-01
        • 1970-01-01
        • 2012-03-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-26
        • 2011-12-08
        相关资源
        最近更新 更多