lopushen opened a new pull request, #333: URL: https://github.com/apache/camel-karaf/pull/333
Fixes https://github.com/apache/camel-karaf/issues/332 Motivation During testing using an OSGI blueprint, it turned out that the camel-spring-rabbitmq no missing bundles to successfully execute the route, but requires an integration test Modifications: Add an integration test for camel-spring-rabbitmq To test manually install ``` repo-add mvn:org.apache.camel.karaf/apache-camel/4.5.0-SNAPSHOT/xml/featuresfeature:install camel-blueprint camel-spring-rabbitmq ``` Launch the docker container `docker run -d --name test_rabbitmq -p 5672:5672 rabbitmq:3.13.1 ` and copy file spring-rabbitmq.xml (or create one with the following content) ``` <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="rabbitConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory"> <argument value="localhost"/> </bean> <bean id="spring-rabbitmq" class="org.apache.camel.component.springrabbit.SpringRabbitMQComponent"> <property name="connectionFactory" ref="rabbitConnectionFactory"/> </bean> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/blueprint"> <route id="rabbitRouteSend"> <from uri="timer://testTimer?fixedRate=true&period=5000"/> <setHeader name="theHeader"> <constant>This is header</constant> </setHeader> <setBody> <constant>Hello Camel</constant> </setBody> <to uri="spring-rabbitmq:exchangeName?routingKey=routingKey"/> <log message="Message sent to RabbitMQ: ${body} headers ${header.theHeader}"/> </route> <route id="rabbitRouteReceive"> <from uri="spring-rabbitmq:exchangeName?routingKey=routingKey"/> <log message="Message received from RabbitMQ: ${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> ``` Observe the following output: ``` 10:42:34.772 INFO [Blueprint Event Dispatcher: 1] Apache Camel 4.5.0 (camelContext) started in 124ms (build:0ms init:0ms start:124ms) 10:42:34.773 INFO [fileinstall-/Users/ylopushen/Talend/demo/apache-karaf-4.4.6/deploy] Started bundle: blueprint:file:/Users/ylopushen/Talend/demo/apache-karaf-4.4.6/deploy/spring-rabbitmq.xml 10:42:34.775 INFO [not.a.Spring.bean-1] SimpleConsumer [queue=spring.gen-8hoQR7V8RJK2fdnX0kQnww, index=0, consumerTag=amq.ctag-UiQ2aOk9Oa5MccKMk_y0pA identity=762797a] started 10:42:35.821 INFO [Camel (camel-1) thread #1 - timer://testTimer] Message sent to RabbitMQ: Hello Camel headers This is header 10:42:35.828 INFO [pool-61-thread-4] Message received from RabbitMQ: Hello Camel headers This is header 10:42:35.828 INFO [pool-61-thread-4] OK - expected This is header 10:42:35.828 INFO [pool-61-thread-4] OK - expected Hello Camel 10:42:40.790 INFO [pool-61-thread-6] Message received from RabbitMQ: Hello Camel headers This is header 10:42:40.790 INFO [Camel (camel-1) thread #1 - timer://testTimer] Message sent to RabbitMQ: Hello Camel headers This is header 10:42:40.791 INFO [pool-61-thread-6] OK - expected This is header 10:42:40.791 INFO [pool-61-thread-6] OK - expected Hello Camel ``` No additional bundles are needed -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org