我正在建立一个简单的ActiveMQ嵌入式代理。它工作正常,直到我尝试配置持久性适配器。我基本上只是从http://activemq.apache.org/persistence.html#Persistence-ConfiguringKahaPersistence复制配置。当我将此配置添加到我的Spring配置时,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.3.0.xsd">
<amq:broker useJmx="true" persistent="true" brokerName="localhost">
<amq:transportConnectors>
<amq:transportConnector name="vm" uri="vm://localhost"/>
</amq:transportConnectors>
<amq:persistenceAdapter>
<amq:kahaPersistenceAdapter directory="activemq-data" maxDataFileLength="33554432"/>
</amq:persistenceAdapter>
</amq:broker>
</beans>
我收到错误:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'amq:persistenceAdapter'.
One of '{WC[##other:"http://activemq.apache.org/schema/core"]}' is expected.
当我取出amq:persistenceAdapter元素时,它工作正常。无论我在主体中包含哪个持久性适配器,都会发生同样的错误,例如: jdbc,journal等。
非常感谢任何帮助。
感谢。
答案 0 :(得分:4)
我不记得为什么目前,但是有一个无意的变化要求元素必须按字母顺序排列。尝试将persistenceAdapter放在transportConnectors之前。
布鲁斯
答案 1 :(得分:0)
关于字母顺序,Apache ActiveMQ XML Reference提及:
从ActiveMQ 5.4开始,元素内的XML元素必须按字母顺序排序。如果你看一下XSD,那么ActiveMQ就是这种情况。 5.4中的区别在于XML配置实际上是针对XML模式进行验证的。
您需要遵循v5.4之前的架构顺序。