Thread: Problem configuration ActiveMQ

本文档记录了在Fuse ESB 4.2环境下配置ActiveMQ遇到的问题及解决过程,包括使用JDBC适配器连接MySQL数据库时出现的依赖缺失错误、XML配置文件语法错误以及消息持久化设置导致的启动失败等问题。
Problem configuration ActiveMQ
Posted: Mar 22, 2010 10:27 AM
  Click to reply to this thread Reply
I have a problem with the ActiveMQ configuration in Fuse ESB 4.2.
I want to use the JDBC persistence adapter and I want to use a database MySQL, so I config the file activemq-broker.xml in this way:


<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" persistent="true" useShutdownHook="false" >
...
<persistenceAdapter>
<journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>
</persistenceAdapter>
...
+ <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/xxxxx?relaxAutoCommit=true"/>+
+ <property name="username" value="root"/>+
+ <property name="password" value="root"/>+
+ <property name="poolPreparedStatements" value="true"/>+
+ </bean>+


but when I startup ServiceMix I obtain in the log file this error:

10:26:02,443 | ERROR | Thread-4 | FeaturesServiceImpl | s.internal.FeaturesServiceImpl$1 677 | Error installing boot features
java.lang.Exception: Could not start bundle spring:file:etc/activemq-broker.xml in feature(s) activemq-broker-4.2.0-fuse-01-00: The bundle could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.commons.dbcp; version="0.0.0"
at org.apache.felix.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:302)
at org.apache.felix.karaf.features.internal.FeaturesServiceImpl$1.run(FeaturesServiceImpl.java:675)
Caused by: org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.commons.dbcp; version="0.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:272)
at org.apache.felix.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:294)
... 1 more

I don't understand the reason of this error and how resolve it....can anyone help me,please!?
ffang

Posts: 323
Registered: 12/24/07
Re: Problem configuration ActiveMQ
Posted: Mar 22, 2010 10:40 AM   in response to: joe in response to: joe
  Click to reply to this thread Reply
Hi,
This error means you didn't install required bundle

do
osgi:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.2.2_5

from the shell.

Freeman
joe

Posts: 5
Registered: 09/09/09
Re: Problem configuration ActiveMQ
Posted: Mar 22, 2010 12:13 PM   in response to: joe in response to: joe
  Click to reply to this thread Reply
Thanks for your help!! You are right!!
Now I enable at startup this bundle and the mysql-connector, but now I have another problem:

12:41:13,270 | ERROR | xtenderThread-12 | ContextLoaderListener | BundleApplicationContextListener 50 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=activemq-broker.xml, config=osgibundle:/META-INF/spring/*.xml))
+org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 22 in XML document from URL bundleentry://134.fwk5226838/META-INF/spring/activemq-broker.xml is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'broker'.+
+ at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)+
+ at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)+
+ at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)+
+ at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)+
+ at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)+
+ at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)+
+ at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:176)+
+ at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:142)+
+ at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)+
+ at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)+
+ at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)+
+ at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:222)+
+ at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:175)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)+
+ at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:718)+
+ at java.lang.Thread.run(Thread.java:595)+
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'broker'.
+ at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)+
+ at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)+
+ at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)+
+ at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)+
+ at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:429)+
+ at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3185)+
+ at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1955)+
+ at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)+
+ at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)+
+ at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)+
+ at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)+
+ at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)+
+ at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)+
+ at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)+
+ at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)+
+ at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)+
+ at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)+
+ at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)+
+ ... 18 more+

I have this config for the activemq-broker.xml file:

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.3.0.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

<broker xmlns="http://activemq.org/config/1.0" brokerName="localhost" persistent="true" useShutdownHook="false" >
...

where is my error??
joe

Posts: 5
Registered: 09/09/09
Re: Problem configuration ActiveMQ and Camel
Posted: Mar 22, 2010 5:55 PM   in response to: joe in response to: joe
  Click to reply to this thread Reply
I found my error here http://activemq.apache.org/xml-reference.html
my mistake depending on fuse message broker documentation.

However now I have a problem to configure activemq inside fuse esb to redelivery messages when the message broker does not shutdown properly.
For my project I use camel and activemq.
This is my camel-context.xml:

<camelContext
+ xmlns="http://camel.apache.org/schema/spring" +
+ xmlns:person="http://servicemix.apache.org/samples/wsdl-first">+

<route>
<from uri="jbi:endpoint:http://servicemix.apache.org/samples/wsdl-first/PersonService/soap" />
+ <to uri="log:pass_1" />+
+ <convertBodyTo type="java.lang.String"/>+
+ <to uri="activemq:topic:codaIn" />+
+ </route>+

+ <route>+
+ <from uri="activemq:topic:codaIn?clientId=testCamelClient&amp;durableSubscriptionName=TopicReader1" />+
+ <multicast>+
+ <to uri="activemq:topic:coda1" />+
+ <to uri="activemq:topic:coda2" />+
+ <to uri="activemq:topic:coda3" />+
+ </multicast>+
</route>

<route errorHandlerRef="errorHandler">
<from uri="activemq:topic:coda1" />
+ <to uri="jbi:endpoint:http://servicemix.apache.org/samples/wsdl-first/PersonServiceT/soapT" />+
+ </route>+

<route errorHandlerRef="errorHandler">
<from uri="activemq:topic:coda2" />
+ <to uri="jbi:endpoint:http://servicemix.apache.org/samples/wsdl-first/PersonServiceP/soapP" />+
+ </route>+

<route errorHandlerRef="errorHandler">
<from uri="activemq:topic:coda3" />
+ <to uri="jbi:endpoint:http://servicemix.apache.org/samples/wsdl-first/PersonServiceN/soapN" />+
+ </route>+
+ +
+ <route errorHandlerRef="errorHandler">+
<from uri="activemq:topic:errori" />
+ <to uri="jbi:endpoint:http://servicemix.apache.org/samples/wsdl-first/PersonServiceP/soapP" />+
+ </route>+

</camelContext>

+ <bean id="errorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">+
+ <property name="deadLetterUri" value="activemq:topic:errori"/>+
+ <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>+
+ </bean>+

+ <bean id="myRedeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy">+
<property name="maximumRedeliveries" value="-1"/>

+ </bean>+

+ <bean id="myRedeliveryPolicyConfig2" class="org.apache.activemq.RedeliveryPolicy">+
<property name="maximumRedeliveries" value="-1"/>
+ </bean>+


<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>

<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="jmsConnectionFactoryProcess"/>

+ </bean>+

<bean id="jmsConnectionFactoryProcess" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616"/>
<property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig2" />
</bean>


With this configuration when I send a message, and for example the endpoint PersonServiceP is down, the message broker continue to redelivery message.
My problem is when a message continue to be redelivery and in the meanwhile occur a disaster and the fuse esb go down!
At the startup the message isn't redelivery....and I obtain a message lost!
How can I avoid this problem?

Edited by: joe on Mar 23, 2010 8:24 AM
joe

Posts: 5
Registered: 09/09/09
Re: Problem configuration ActiveMQ
Posted: Mar 24, 2010 9:51 AM   in response to: joe in response to: joe
  Click to reply to this thread Reply
I've followed this configuration for Activemq http://activemq.apache.org/amq-message-store.html
but when I kill servicemix, delete the idex-store-state file and then I restart servicemix, I obtain an error of activemq:

...
10:16:32,372 | ERROR | xtenderThread-18 | BrokerService | he.activemq.broker.BrokerService 496 | Failed to start ActiveMQ JMS Message Broker. Reason: java.io.EOFException
java.io.EOFException
+ at java.io.RandomAccessFile.readFully(RandomAccessFile.java:373)+
+ at java.io.RandomAccessFile.readFully(RandomAccessFile.java:351)+
+ at org.apache.activemq.kaha.impl.index.StoreIndexReader.readItem(StoreIndexReader.java:46)+
+ at org.apache.activemq.kaha.impl.index.IndexManager.getIndex(IndexManager.java:70)+
+ at org.apache.activemq.kaha.impl.IndexRootContainer.getRoot(IndexRootContainer.java:126)+
+ at org.apache.activemq.kaha.impl.KahaStore.generateInterestInMapDataFiles(KahaStore.java:564)+
+ at org.apache.activemq.kaha.impl.KahaStore.initialize(KahaStore.java:486)+
+ at org.apache.activemq.kaha.impl.KahaStore.getMapContainerIds(KahaStore.java:251)+
+ at org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter.start(KahaReferenceStoreAdapter.java:96)+
+ at org.apache.activemq.store.amq.AMQPersistenceAdapter.start(AMQPersistenceAdapter.java:233)+
+ at org.apache.activemq.broker.BrokerService.start(BrokerService.java:456)+
+ at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:61)+
+ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)+
+ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)+
+ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)+
+ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)+
+ at java.security.AccessController.doPrivileged(Native Method)+
+ at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)+
+ at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)+
+ at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)+
+ at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)+
+ at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)+
+ at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)+
+ at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)+
+ at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)+
+ at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)+
+ at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)+
+ at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)+
+ at java.lang.Thread.run(Thread.java:595)+
...

and so Activemq don't start! Where's my error??
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值