I'm using Camel (with the camel-ejb dependency) to route messages from an ActiveMQ to my bean's method. So far I've got it receiving the message in my requestHandler bean.
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="tcp://localhost:61616" />
<bean class="org.springframework.jms.connection.CachingConnectionFactory"
id="connectionFactory">
<constructor-arg ref="amqConnectionFactory" />
<property name="sessionCacheSize" value="100" />
</bean>
<bean class="org.springframework.jms.core.JmsTemplate" id="jmsTemplate">
<constructor-arg ref="connectionFactory" />
</bean>
<camel:camelContext id="camelContext">
<camel:route>
<camel:from uri="activemq:queue:inQueue" />
<camel:setExchangePattern pattern="InOut"/>
<camel:to uri="bean:requestHandler?method=handleRequest" />
</camel:route>
</camel:camelContext>
If I now change handleRequest to return a String, how would I modify my route to put the String on the queue back to the person sending me a message?
Thanks!
EDIT:
Client code:
(in camel-context.xml)
<camel:camelContext id="camel-client">
<camel:template id="camelTemplate" />
</camel:camelContext>
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
(in CamelClient.java)
public class CamelClient {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("camel-context.xml");
ProducerTemplate pTemplate = context.getBean("camelTemplate", ProducerTemplate.class);
System.out.println("Message Sending started");
String ret = pTemplate.requestBody("activemq:queue:inQueue", "47264", String.class);
System.out.println("Message received:" + ret);
}
}