Am 100% new to JMS and Camel
This is the Scenario
I have a Spring Web application, a JMS (ActiveMQ), Camel
The web application needs to send information to JSM, through camel in an asynchronous manner. i.e. After sending information to Camel, the website should not wait for the response. The web page should continue.
And , my application should listen to the queue for any response in the Queue. Once , any response is received, a specific bean has to be invoked.
Is this possible???
This is the configuration in my client
Camel Context :
<!-- START SNIPPET: e1 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
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">
<!-- END SNIPPET: e1 -->
<!-- START SNIPPET: e2 -->
<camel:camelContext id="camel-client">
<camel:template id="camelTemplate"/>
</camel:camelContext>
<!-- END SNIPPET: e2 -->
<!-- START SNIPPET: e3 -->
<!-- Camel JMSProducer to be able to send messages to a remote Active MQ server -->
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61610"/>
</bean>
<!-- END SNIPPET: e3 -->
</beans>
Camel Code :
ApplicationContext context = new ClassPathXmlApplicationContext("camel-client.xml");
// get the camel template for Spring template style sending of messages (= producer)
ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class);
System.out.println("Invoking the multiply with 22");
// as opposed to the CamelClientRemoting example we need to define the service URI in this java code
int response = (Integer)camelTemplate.sendBody("jms:queue:numbers", ExchangePattern.InOut, 22);
System.out.println("... the result is: " + response);
This is working good. But the prblem is , this is synchronous.
I want this to be asynchronous.
How to do it