<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:queue:inputQueue"/>
<to uri="bean:messageHandler"/>
<to uri="jms:queue:outputQueue"/>
</route>
</camelContext>
<bean id="messageHandler" class="com.example.MessageHandler"/>
</beans>
package com.example;
public class MessageHandler {
public String handleMessage(String body) {
return "Processed: " + body;
}
}
shell
./camel run camel-jms-java-route.xml
package com.example;
import org.apache.camel.main.Main;
public class App {
public static void main(String[] args) throws Exception {
Main main = new Main();
main.configure().addRoutesBuilder(new CamelJmsJavaRouteBuilder());
main.run();
}
}