【发布时间】:2013-01-06 02:19:09
【问题描述】:
我 100% 是 JMS 和 Camel 的新手
这是场景
我有一个 Spring Web 应用程序、一个 JMS (ActiveMQ)、Camel
Web 应用程序需要通过 Camel 以异步方式向 JSM 发送信息。 即向 Camel 发送信息后,网站不应等待响应。网页应该会继续。
而且,我的应用程序应该监听队列以获取队列中的任何响应。一旦收到任何响应,就必须调用特定的 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);
这很好用。但问题是,这是同步的。
我希望这是异步的。
怎么做
【问题讨论】:
-
那样的话,怎么可能呢?更新我的问题
标签: spring jms apache-camel