We put a blueprint file in the karaf/deploy directory to create the JNDI entry of the JMS Connection Factory.
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616" /> <property name="userName" value=“xxx" /> <property name="password" value=“xxx" /> </bean> <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop"> <property name="maxConnections" value="8" /> <property name="connectionFactory" ref="jmsConnectionFactory" /> </bean> <service interface="javax.jms.ConnectionFactory" ref="pooledConnectionFactory"> <service-properties> <entry key="osgi.jndi.service.name" value="jms/ActiveMqJmsConnectionFactory"/> </service-properties> </service> </blueprint> Then we import a common spring doc from a common component. <import resource="classpath:/META-INF/spring/activemq/activemq-config.xml" /> Here is activemq-config.xml. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="pooledConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="osgi:service/jms/ActiveMqJmsConnectionFactory" /> </bean> <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory" ref="pooledConnectionFactory" /> </bean> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="configuration" ref="jmsConfig" /> </bean> </beans> Don’t forget to have the Felix plugin on the common component export META-INF.spring.activemq, and the Felix plugin of your Camel service component import META-INF.spring.activemq. Thanks, Joe Kampf On 3/4/16, 11:03 AM, "Thomas Weinschenk" <[email protected]> wrote: >Hi folks, > >Is there a way to set configuration of the AMQ component globally? So far I >have to include the configurations in every blueprint xml or publish the >JmsConfiguration as an OSGi service and then include the reference in every >blueprint. This is even more annoying because the JmsConfiguration is not an >interface and therefore I also have to include the blueprint-ext… >Is there a better way to share the setting and/or the connection factory? > >Regards, >Thomas > > > >-- >View this message in context: >http://camel.465427.n5.nabble.com/Globally-set-ActiveMQ-configuations-in-Karaf-OSGi-or-share-the-connection-factory-tp5778631.html >Sent from the Camel - Users mailing list archive at Nabble.com.
