Hi,

you can configure the jmsConnectionFacotry in one blueprint like this:

<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="xxxxx" />
        <property name="password" value="xxxxx" />
    </bean>

    <service interface="javax.jms.ConnectionFactory"
ref="jmsConnectionFactory"/>

</blueprint>

and then you can use this factory in several:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>

   <reference id="foo" interface="javax.jms.ConnectionFactory"/>

   <camelContext ...>
      <route>
       <from uri="jms:queue:myqueue?connectionFactory=foo"/>
       ...
      </route>
   </camelContext>      

</blueprint>

NB: I would use a pooled connection factory.

You can find some example there: http://blog.nanthrax.net/?p=820

Regards
JB

On 13/01/2020 10:55, Gerald Kallas wrote:
> Hi JB,
> 
> finally this works ..
> 
> feature:repo-add hawtio 2.8.0
> feature:repo-add activemq 5.15.11
> feature:repo-add camel 3.0.0
> 
> feature:install webconsole hawtio activemq-broker-noweb camel camel-jms jms 
> pax-jms-config pax-jms-activemq
> 
> with the route
> 
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
> 
>       <!-- set JMS connection factory -->
>       <bean id="jmsConnectionFactory" 
> class="org.apache.activemq.ActiveMQConnectionFactory">
>               <property name="brokerURL" value="tcp://localhost:61616" />
>               <property name="userName" value="xxxxx" />
>               <property name="password" value="xxxxx" />
>       </bean>
> 
>       <camelContext id="activemq" 
> xmlns="http://camel.apache.org/schema/blueprint"; streamCache="true">
> 
>               <route id="activemq">
>                       <!-- trigger file for testing purposes -->
>                       <from 
> uri="file:E:/tmp/in?include=.*\.xml&amp;moveFailed=error" />
>                       <to uri="jms:queue:IN" />
>               </route>
> 
>       </camelContext>
> 
> </blueprint>
> 
> The only thing that I'm still missing is to configure the JMS connection 
> factory system wide (with pax?). I don't want to configure this again in each 
> blueprint file.
> 
> ActiveMQ doesn't support JMS 2.0 so this doesn't work
> https://ops4j1.jira.com/wiki/spaces/PAXJMS/pages/331350050/Configuration
> 
> May be any other way around works?
> 
> Best
> - Gerald
> 
> P.S. I saw this sentence within the Camel JMS documentation ..
> 
> USING ACTIVEMQ
> The JMS component reuses Spring 2’s JmsTemplate for sending messages. This is 
> not ideal for use in a non-J2EE container and typically requires some caching 
> in the JMS provider to avoid poor performance.
> 
> If you intend to use Apache ActiveMQ as your message broker, the 
> recommendation is that you do one of the following:
> 
> Use the ActiveMQ component, which is already optimized to use ActiveMQ 
> efficiently
> 
> Use the PoolingConnectionFactory in ActiveMQ.
> 
> 
> Does that really matter an when?
> 
>> Jean-Baptiste Onofré <j...@nanthrax.net> hat am 13. Januar 2020 um 07:24 
>> geschrieben:
>>
>>
>> Hi Gerald,
>>
>> That's not fully correct. ActiveMQ component gives you some deep
>> configuration but 99% of the features can be achieved with camel-jms.
>>
>> In Karaf, you can just create a ActiveMQ connection factory (using jms
>> feature/commands), and use this connection factory directly with camel-jms.
>>
>> On my blog (blog.nanthrax.net), you have several examples how to use
>> ActiveMQ with Camel JMS.
>>
>> If you need some details/helps, don't hesitate to ping me directly.
>>
>> Regards
>> JB
>>
>> On 13/01/2020 07:01, Gerald Kallas - mailbox.org wrote:
>>> Hi JB,
>>>
>>> tx for the comprehensive reply.
>>>
>>> Within the Camel documentation I read that the activemq component is 
>>> optimized for ActiveMQ. So what does that mean and where are the 
>>> differences between the activemq and the camel-jms component? What does the 
>>> jms component provide?
>>>
>>> Sent by my mobile device
>>> - Gerald Kallas
>>>
>>>> Am 13.01.2020 um 06:00 schrieb Jean-Baptiste Onofré <j...@nanthrax.net>:
>>>>
>>>> Hi Gerald,
>>>>
>>>> Again camel-activemq is not require: you can directy use JMS. It's what
>>>> I'm always doing. The ActiveMQ connection factory in Karaf (most of the
>>>> time I have ActiveMQ broker standalone outside of the Karaf runtime) and
>>>> using jms in my Camel routes.
>>>>
>>>> Anyway, the ActiveMQServiceFactory.updated means you have a refresh or a
>>>> configuration change (in etc/activemq.xml). I'm suspecting hawtio to
>>>> cause this.
>>>>
>>>> If you do feature:install -v you will see the refresh and the cause of
>>>> the refresh. I will reproduce it to identify the root cause.
>>>>
>>>> Regards
>>>> JB
>>>>
>>>>> On 12/01/2020 21:59, Gerald Kallas wrote:
>>>>> Hi JB,
>>>>>
>>>>> feature:install camel
>>>>>
>>>>> instead of
>>>>>
>>>>> feature:install camel-blueprint
>>>>>
>>>>> did it finally without the jaxb exception. btw, I'm running Java 8.
>>>>>
>>>>> Nevertheless, the feature camel-activemq is required to use the activemq 
>>>>> component. This I did finally
>>>>>
>>>>> karaf@root()> feature:repo-add hawtio 2.8.0
>>>>> Adding feature url mvn:io.hawt/hawtio-karaf/2.8.0/xml/features
>>>>> karaf@root()> feature:repo-add activemq 5.15.11
>>>>> Adding feature url 
>>>>> mvn:org.apache.activemq/activemq-karaf/5.15.11/xml/features
>>>>> karaf@root()> feature:repo-add camel 3.0.0
>>>>> Adding feature url 
>>>>> mvn:org.apache.camel.karaf/apache-camel/3.0.0/xml/features
>>>>> karaf@root()> feature:install webconsole hawtio activemq-broker-noweb 
>>>>> camel camel-activemq
>>>>>
>>>>> The error
>>>>>
>>>>>        at 
>>>>> org.apache.activemq.osgi.ActiveMQServiceFactory.updated(ActiveMQServiceFactory.java:147)
>>>>>  ~[!/:5.15.11]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.updated(ManagedServiceFactoryTracker.java:159)
>>>>>  ~[!/:?]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.provideConfiguration(ManagedServiceFactoryTracker.java:93)
>>>>>  [!/:?]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.provide(ConfigurationManager.java:1253)
>>>>>  [!/:?]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1197)
>>>>>  [!/:?]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138) [!/:?]
>>>>>        at 
>>>>> org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105) [!/:?]
>>>>>        at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
>>>>> Caused by: javax.management.InstanceAlreadyExistsException: 
>>>>> org.apache.activemq:type=Broker,brokerName=amq-broker
>>>>>
>>>>> remains the same. Seems that there is a doubled activemq startup sequence 
>>>>> somewhere. The system runs but the error message may confuse the 
>>>>> operating people finally.
>>>>>
>>>>> Any further hints at this?
>>>>>
>>>>> Thanks
>>>>> - Gerald
>>>>>
>>>>>> Jean-Baptiste Onofré <j...@nanthrax.net> hat am 12. Januar 2020 um 21:06 
>>>>>> geschrieben:
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I guess you are using Java 11 ? That's JAXB version (it should work
>>>>>> without change with JDK8).
>>>>>>
>>>>>> Do you use JAXB from JDK or from bundle ?
>>>>>>
>>>>>> Regards
>>>>>> JB
>>>>>>
>>>>>> On 12/01/2020 19:06, Gerald Kallas wrote:
>>>>>>> Tx JB.
>>>>>>>
>>>>>>> I did the same steps as you provided. Afterwards I created a simple 
>>>>>>> route as following ..
>>>>>>>
>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
>>>>>>>
>>>>>>>    <!-- set JMS connection factory -->
>>>>>>>    <bean id="jmsConnectionFactory" 
>>>>>>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>>>>        <property name="brokerURL" value="tcp://localhost:61616" />
>>>>>>>        <property name="userName" value="karaf" />
>>>>>>>        <property name="password" value="karaf" />
>>>>>>>    </bean>
>>>>>>>
>>>>>>>    <camelContext id="activemq" 
>>>>>>> xmlns="http://camel.apache.org/schema/blueprint"; streamCache="true">
>>>>>>>
>>>>>>>        <route id="activemq">
>>>>>>>            <!-- trigger file for testing purposes -->
>>>>>>>            <from uri="file:E:/tmp/in?include=.*\.xml&moveFailed=error" 
>>>>>>> />
>>>>>>>            <to uri="activemq:queue:IN" />
>>>>>>>        </route>
>>>>>>>
>>>>>>>    </camelContext>
>>>>>>>
>>>>>>> </blueprint>
>>>>>>>
>>>>>>> While trying to deploy the route I'm getting
>>>>>>>
>>>>>>> java.lang.NoClassDefFoundError: com/sun/istack/FinalArrayList
>>>>>>>        at 
>>>>>>> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:249)
>>>>>>>  ~[?:?]
>>>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown 
>>>>>>> Source) ~[?:1.8.0_201]
>>>>>>>        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
>>>>>>>        at 
>>>>>>> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:143) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at javax.xml.bind.ContextFinder.find(ContextFinder.java:310) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at javax.xml.bind.JAXBContext.newInstance(Unknown Source) 
>>>>>>> ~[?:1.8.0_201]
>>>>>>>        at 
>>>>>>> org.apache.camel.impl.DefaultModelJAXBContextFactory.newJAXBContext(DefaultModelJAXBContextFactory.java:38)
>>>>>>>  ~[?:?]
>>>>>>>        at 
>>>>>>> org.apache.camel.blueprint.handler.CamelNamespaceHandler.getJaxbContext(CamelNamespaceHandler.java:678)
>>>>>>>  ~[?:?]
>>>>>>> ...
>>>>>>>
>>>>>>> Any idea about this?
>>>>>>>
>>>>>>> Best
>>>>>>> - Gerald
>>>>>>>
>>>>>>>> Jean-Baptiste Onofré <j...@nanthrax.net> hat am 12. Januar 2020 um 
>>>>>>>> 16:22 geschrieben:
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> First, you don't need camel-activemq feature, just camel-jms is enough.
>>>>>>>>
>>>>>>>> The activemq-broker-noweb feature seems to work fine, so you have
>>>>>>>> probably a refresh.
>>>>>>>>
>>>>>>>> Here's what I did:
>>>>>>>>
>>>>>>>> feature:install webconsole
>>>>>>>> feature:repo-add activemq 5.15.11
>>>>>>>> feature:repo-add camel 3.0.0
>>>>>>>> feature:install activemq-broker-noweb
>>>>>>>> feature:install camel-blueprint
>>>>>>>> feature:install camel-jms
>>>>>>>> feature:install jms
>>>>>>>>
>>>>>>>> I don't have any issue so far (activemq:bstat is fine with an unique
>>>>>>>> broker).
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> JB
>>>>>>>>
>>>>>>>> On 12/01/2020 15:57, Gerald Kallas wrote:
>>>>>>>>> Dear community,
>>>>>>>>>
>>>>>>>>> I'm going to setup a vanilla karaf / activemq / camel3 installation 
>>>>>>>>> with the following commands
>>>>>>>>>
>>>>>>>>> karaf@root()> feature:repo-add hawtio 2.8.0
>>>>>>>>> Adding feature url mvn:io.hawt/hawtio-karaf/2.8.0/xml/features
>>>>>>>>> karaf@root()> feature:repo-add activemq 5.15.11
>>>>>>>>> Adding feature url 
>>>>>>>>> mvn:org.apache.activemq/activemq-karaf/5.15.11/xml/features
>>>>>>>>> karaf@root()> feature:repo-add camel 3.0.0
>>>>>>>>> Adding feature url 
>>>>>>>>> mvn:org.apache.camel.karaf/apache-camel/3.0.0/xml/features
>>>>>>>>> karaf@root()> feature:install webconsole
>>>>>>>>> karaf@root()> feature:install hawtio
>>>>>>>>> karaf@root()> feature:install activemq-broker-noweb
>>>>>>>>> karaf@root()> feature:install camel
>>>>>>>>> karaf@root()> feature:install camel-jms
>>>>>>>>> karaf@root()> feature:install camel-activemq
>>>>>>>>>
>>>>>>>>> The last command caused an error that comes on board again when 
>>>>>>>>> restarting karaf
>>>>>>>>>
>>>>>>>>> org.osgi.service.cm.ConfigurationException: null : Cannot start the 
>>>>>>>>> broker
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.osgi.ActiveMQServiceFactory.updated(ActiveMQServiceFactory.java:147)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> at 
>>>>>>>>> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.updated(ManagedServiceFactoryTracker.java:159)
>>>>>>>>>  ~[!/:?]
>>>>>>>>> at 
>>>>>>>>> org.apache.felix.cm.impl.helper.ManagedServiceFactoryTracker.provideConfiguration(ManagedServiceFactoryTracker.java:93)
>>>>>>>>>  [!/:?]
>>>>>>>>> at 
>>>>>>>>> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.provide(ConfigurationManager.java:1253)
>>>>>>>>>  [!/:?]
>>>>>>>>> at 
>>>>>>>>> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1197)
>>>>>>>>>  [!/:?]
>>>>>>>>> at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:138) 
>>>>>>>>> [!/:?]
>>>>>>>>> at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:105) 
>>>>>>>>> [!/:?]
>>>>>>>>> at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
>>>>>>>>> Caused by: javax.management.InstanceAlreadyExistsException: 
>>>>>>>>> org.apache.activemq:type=Broker,brokerName=amq-broker
>>>>>>>>> at com.sun.jmx.mbeanserver.Repository.addMBean(Unknown Source) 
>>>>>>>>> ~[?:1.8.0_201]
>>>>>>>>> at 
>>>>>>>>> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(Unknown
>>>>>>>>>  Source) ~[?:1.8.0_201]
>>>>>>>>> at 
>>>>>>>>> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown
>>>>>>>>>  Source) ~[?:1.8.0_201]
>>>>>>>>> at 
>>>>>>>>> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown
>>>>>>>>>  Source) ~[?:1.8.0_201]
>>>>>>>>> at 
>>>>>>>>> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown
>>>>>>>>>  Source) ~[?:1.8.0_201]
>>>>>>>>> at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown 
>>>>>>>>> Source) ~[?:1.8.0_201]
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:409)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.broker.jmx.AnnotatedMBean.registerMBean(AnnotatedMBean.java:93)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.broker.BrokerService.startManagementContext(BrokerService.java:2627)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.broker.BrokerService.start(BrokerService.java:621)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> at 
>>>>>>>>> org.apache.activemq.osgi.ActiveMQServiceFactory.updated(ActiveMQServiceFactory.java:141)
>>>>>>>>>  ~[!/:5.15.10]
>>>>>>>>> ... 7 more
>>>>>>>>>
>>>>>>>>> I tried some other sequences, always the same. Seems that the broker 
>>>>>>>>> attempted to start twice.
>>>>>>>>>
>>>>>>>>> Any hints and suggestions are highly appreciated.
>>>>>>>>>
>>>>>>>>> Best
>>>>>>>>> - Gerald
>>>>>>>>>
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> Jean-Baptiste Onofré
>>>>>>>> jbono...@apache.org
>>>>>>>> http://blog.nanthrax.net
>>>>>>>> Talend - http://www.talend.com
>>>>>>
>>>>>> -- 
>>>>>> Jean-Baptiste Onofré
>>>>>> jbono...@apache.org
>>>>>> http://blog.nanthrax.net
>>>>>> Talend - http://www.talend.com
>>>>
>>>> -- 
>>>> Jean-Baptiste Onofré
>>>> jbono...@apache.org
>>>> http://blog.nanthrax.net
>>>> Talend - http://www.talend.com
>>>
>>
>> -- 
>> Jean-Baptiste Onofré
>> jbono...@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to