lopushen opened a new pull request, #272:
URL: https://github.com/apache/camel-karaf/pull/272

   Fixes https://github.com/apache/camel-karaf/issues/271
   
   ### Motivation
   During testing using an OSGI blueprint, it turned out that the camel-amqp 
and camel-activemq are missing bundles to successfully execute the route. Since 
these two features both and the only ones that depend upon camel-jms, and the 
micrometer dependency should be added to camel-jms, the fixes for both features 
are united in a single PR.
   
   ### Modifications:
   Add a workaround for spring-jms SMX bundle to contain micrometer until 
https://issues.apache.org/jira/browse/SM-5706 is resolved and released
   Add missing bundles for both features to run
   
   **camel-amqp** was tested with
   ```
   <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
              
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
              xsi:schemaLocation="
                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
                http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                http://camel.apache.org/schema/blueprint 
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
   
       <bean id="amqpConnectionDetails" 
class="org.apache.camel.component.amqp.AMQPConnectionDetails">
           <argument value="amqp://localhost:5672"/>
       </bean>
   
   
       <camelContext id="camelContext" 
xmlns="http://camel.apache.org/schema/blueprint";>
           <route id="amqpRoute">
               <from uri="timer://testTimer?fixedRate=true&amp;period=5000"/>
               <setHeader name="theHeader">
                   <constant>This is header</constant>
               </setHeader>
               <setBody>
                   <constant>Hello Camel</constant>
               </setBody>
               <to uri="amqp:amqpQueueName"/>
               <log message="Message sent to AMQP: ${body} headers 
${header.theHeader}"/>
           </route>
   
           <route id="amqpRoute2">
               <from uri="amqp:amqpQueueName"/>
               <log message="Message received from AMQP: ${body} headers 
${header.theHeader}"/>
               <choice>
                   <when>
                       <simple>${header.theHeader} != "This is header"</simple>
                       <log message="KO - not expected ${header.theHeader}"/>
                       <throwException exceptionType="java.lang.Exception" 
message="An unexpected header returned"/>
                   </when>
                   <otherwise>
                       <log message="OK - expected ${header.theHeader}"/>
                       
                   </otherwise>
               </choice>
               <choice>
                   <when>
                       <simple>${body} != "Hello Camel"</simple>
                       <log message="KO - not expected ${body}"/>
                       <throwException exceptionType="java.lang.Exception" 
message="An unexpected body returned"/>
                   </when>
                   <otherwise>
                       <log message="OK - expected ${body}"/>
                   </otherwise>
               </choice>
           </route>
   
       </camelContext>
   
   </blueprint>
   ```
   
   **camel-activemq** was tested with
   ```
   <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
              
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
              xsi:schemaLocation="
                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
                http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                http://camel.apache.org/schema/blueprint 
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
   
   
       <bean id="activemqConfig" 
class="org.apache.camel.component.activemq.ActiveMQConfiguration">
           <property name="connectionFactory" ref="activemqConnectionFactory"/>
       </bean>
   
        <bean id="activemqConnectionFactory" 
class="org.apache.activemq.ActiveMQConnectionFactory">
           <argument value="tcp://localhost:61616"/>
           <property name="watchTopicAdvisories" value="false"/>
                   <property name="userName" value="myUser"/>
           <property name="password" value="myPassword"/> 
       </bean>
   
       <bean id="activemq" 
class="org.apache.camel.component.activemq.ActiveMQComponent">
           <property name="configuration" ref="activemqConfig"/>
       </bean>
   
       <camelContext id="camel" 
xmlns="http://camel.apache.org/schema/blueprint";>
           <route id="activeMqProducerRoute">
               <from uri="timer://myTimer?fixedRate=true&amp;period=5000"/>
               <setBody>
                   <simple>Hello Camel</simple>
               </setBody>
               <log message="Sending message to ActiveMQ: ${body}"/>
               <to uri="activemq:queue:activemqQueueName"/>
               <log message="Message sent to ActiveMQ: ${body}"/>
           </route>
           <route id="activeMqConsumerRoute">
           <from uri="activemq:queue:activemqQueueName"/>
           <log message="Message received from ActiveMQ: ${body}"/>
           </route>
       </camelContext>
   
   </blueprint>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to