現在是一個100%新JMS和駱駝春天,駱駝,JMS集成
這是該方案
我有一個春天的Web應用程序,JMS(ActiveMQ的),駱駝
Web應用程序需要通過異步方式將信息發送給JSM。 即向駱駝發送信息後,網站不應等待迴應。網頁應該繼續。
而且,我的應用程序應該監聽隊列中隊列中的任何響應。一旦收到任何響應,就必須調用特定的bean。
這可能嗎?
這是配置我的客戶
駱駝語境:
<!-- 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>
駱駝代碼:
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);
這是工作好。但問題是,這是同步的。
我希望這是異步的。
怎麼辦呢
是的,這是可能的。 –
在這種情況下,它怎麼可能?更新我的問題 – madhairsilence