JMS と Camel はまったくの初心者です
これがシナリオです
Spring Web アプリケーション、JMS (ActiveMQ)、Camel があります。
Web アプリケーションは、camel を介して非同期で JSM に情報を送信する必要があります。つまり、Camel に情報を送信した後、Web サイトは応答を待つべきではありません。Web ページは続行する必要があります。
そして、私のアプリケーションは、キュー内の応答についてキューをリッスンする必要があります。応答が受信されると、特定の 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);
これはうまくいっています。しかし問題は、これは同期です。
これを非同期にしたい。
どうやってするの