我有两个带有骆驼-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>
如果我在第二个捆绑蓝图文件中使用常量值,一切都可以正常工作。一旦我在那里使用像 ${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
..
..
..
如果我使用第二个配置文件,它只是像com.mycompany.context_1这样的重复配置文件,那么第一个捆绑包无法通过以下事务相关消息解析。 以下捆绑包在优雅中的原因是什么?
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()>
从蓝图文件中删除所有默认条目已解决此问题。 并且使用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>