4

Web サービス要求を jms キューの InOnly エンドポイントにルーティングしたいと考えています。次に、別の InOnly エンドポイントから受信した応答 jms メッセージを、応答として Web サービス クライアントにルーティングします。Web サービスの要求/応答は同期 InOut パターンで、サブルートは非同期です。Camelでこれを達成するには、どのようなオプションが必要ですか?

ここの Camel ルートは、私の質問を説明するために使用されます。

String uri={webserice uri}
from(uri)    
    .process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            ServcieRequest req =            
            exchange.getIn().getBody(ServcieRequest.class);                 
            // One option to me is to spawn another route here to route to jms queue...         
            ProducerTemplate template = exchange.getContext().createProducerTemplate();
            template.sendBodyAndHeaders("jms:queue:INQueue", req.getPayload(), headers);
            // then need to wait ...until received jms response from the route below        

   }});


from("jms:queue:OUTQueue")
   .process(new Processor() {
       public void process(Exchange exchange) throws Exception {
           // received jms response message
           // need to update the exchange data in the above route based on jms message
           // so the final response to the webservice cilent can receive the data ...
       }});
4

1 に答える 1

2

このタスクについては、Camel のリクエスト応答メカニズムに依存する必要があると思います。 Camel Doc、専用固定返信キュー

したがって、次の DSL ルートは、ほとんどあなたが望むことを行うと思います (JMS 部分に InOnly パターンを使用する理由が他にない場合は?)。必要に応じて requestTimeout を調整してください (デフォルトで 20 秒のタイムアウトになっているため)。

from(webserviceURI)
  .inOut().to("jms:queue:INQueue?replyTo=OUTQueue?replyToType=Exclusive");

はい、もう 1 つ。これを複数のノードで実行する場合は、ノードごとに 1 つの専用キューが必要です。

于 2012-04-21T20:35:04.327 に答える