我有两个蓝图文件包,包含camel-activemq东西。 喜欢
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
..
<cm:property-placeholder id="jms.placeholder" persistent-id="com.mycompany.context">
<cm:default-properties>
<cm:property name="activemq.url" value="${activemq.url}" />
<cm:property name="activemq.user" value="${activemq.user}" />
<cm:property name="activemq.password" value="${activemq.password}" />
</cm:default-properties>
</cm:property-placeholder>
..
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
id="quartzCamelPublisher"
autoStartup="true">
<route id="failedMessagePublisher">
<from uri="vm:failedEventQueue" />
<to pattern="InOnly" uri="activemq:queue:not-success"/>
</route>
</camelContext>
<reference id="txMgr" interface="javax.transaction.TransactionManager" />
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
<property name="userName" value="${activemq.user}" />
<property name="password" value="${activemq.password}" />
<property name="watchTopicAdvisories" value="false" />
</bean>
<bean id="jcaConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="transactionManager" ref="txMgr"/>
<property name="maxConnections" value="10" />
<property name="name" value="amq" />
<property name="connectionFactory" ref="xaConnectionFactory"/>
</bean>
<bean id="jmsTxConf" class="org.apache.activemq.camel.component.ActiveMQConfiguration">
<property name="connectionFactory" ref="jcaConnectionFactory" />
<property name="requestTimeout" value="10000" />
<property name="transactionTimeout" value="30" />
<property name="transacted" value="true" />
<property name="cacheLevelName" value="CACHE_NONE" />
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="configuration" ref="jmsTxConf" />
</bean>
</blueprint>
&#13;
如果我在第二个捆绑蓝图文件中使用常量值,那么每件事都可以正常工作。我很快就会使用$ {activemq.url}之类的配置,它看起来无法找到它并尝试获得无限的时间。第二捆无法在那里解决。
018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,133 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,138 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,139 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,139 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,140 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,140 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,141 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from configuration with pid com.mycompany.context
2018-05-22 13:00:13,143 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving property activemq.url
2018-05-22 13:00:13,143 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieved property activemq.url value from defaults ${activemq.url}
2018-05-22 13:00:13,144 | DEBUG | rint Extender: 2 | PropertyPlaceholder | 35 - org.apache.aries.blueprint.core - 1.8.2 | Retrieving Value from expression: activemq.url
2018-05-22 13:00:13,144 | DEBUG | rint Extender: 2 | CmPropertyPlaceholder | 34 - org.apache.aries.blueprint.cm - 1.1.0 | Retrieving property value activemq.url from
..
..
..
&#13;
如果我使用第二个配置文件,它只是像com.mycompany.context_1这样的重复配置文件,那么第一个包无法通过以下事务关联消息解析。 捆绑在graceperiond之后的原因是什么?
karaf@root()> bundle:diag 128
ReturnContext :: My Bundle (128)
----------------------------------------------
Status: GracePeriod
Blueprint
22/5/18 12:53 PM
Missing dependencies:
(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://aries.apache.org/xmlns/transactions/v2.0.0))
Declarative Services
karaf@root()> feature:list | grep transaction
transaction-api | 1.2.0 | | Started | enterprise-4.1.2 |
transaction-manager-geronimo | 1.3.3 | | Started | enterprise-4.1.2 | Geronimo Transaction Manager
transaction-manager-narayana | 5.5.2.Final | | Uninstalled | enterprise-4.1.2 | Narayana Transaction Manager
transaction | 2.0.0 | | Started | enterprise-4.1.2 | OSGi Transaction Manager
karaf@root()>
&#13;
答案 0 :(得分:0)
从蓝图文件中删除所有默认条目已修复此问题。 使用cofig文件中的属性也可以。
<?xml version="1.0" encoding="UTF-8"?>
<blueprint ...
<cm:property-placeholder id="jms.placeholder" persistent-id="com.mycompany.context">
<cm:default-properties>
</cm:default-properties>
</cm:property-placeholder>
....
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
<property name="userName" value="${activemq.user}" />
<property name="password" value="${activemq.password}" />
<property name="watchTopicAdvisories" value="false" />
</bean>
...
</blueprint>