2017-10-10 10 views
0

webserviceとjmsキューに基づいてCamelの動的ルーティングマネージャで作業しています。私はこの次のアーキテクチャを持っている:ここではキャメルとの動的ルーティングはメッセージを転送しません

endpoint:cxf -> jms:queue -> dynamic routing to a jms:queue -> processing 

は私のルートの定義です:

@Override 
public void configure() throws Exception { 
    routeDefinition = from(fromEndpoint).routeId(name) 
      .dynamicRouter(method(DynamicRoutingManager.class, "getRoute")).process(exchange -> { 
       final List<?> soaList = exchange.getIn().getBody(List.class); 
       final String type = (String) soaList.get(0); 
       final String documentNumber = (String) soaList.get(1); 
       final String productionStepNumber = (String) soaList.get(2); 
       final String message = (String) soaList.get(3); 

       final String messageToSend = "Route ID=" + name + ", from=" + fromEndpoint + ", type=" + type 
         + ", document number=" + documentNumber + ", production step number" + productionStepNumber 
         + ", message=" + message; 
       LOG.debug("==> message={}", messageToSend); 
       exchange.getOut().setBody(messageToSend); 
      }); // .to(DLQ); 
} 

とここに私のダイナミックルーティングマネージャ(私はそれをシンプルに保つ):

public String getRoute(String body, @Header(Exchange.SLIP_ENDPOINT) String previous) { 
    LOG.debug("========> BODY={}", body); 
    return "jms:topic:urgent_doc1_prod1"; 
} 

ルートjms:topic:urgent_doc1_prod1実行時と実行時に定義されます(ログ内のビュー)

実際はwhです私はそのような要求を送信する途中、私は私のメッセージは、2番目のJMSにforwaredされていないと思う原因..​​.私はタイムアウトエラーを取得

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hel="http://cxf.apache.org/wsse/handler/helloworld"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <hel:message> 
     <!--Optional:--> 
     <type>urgent</type> 
     <!--Optional:--> 
     <document_number>1</document_number> 
     <!--Optional:--> 
     <production_step_number>1</production_step_number> 
     <!--Optional:--> 
     <message>un message</message> 
     </hel:message> 
    </soapenv:Body> 
</soapenv:Envelope> 

(下記参照):キューので、任意の処理を行うことができます...

私は間違っていますか?

答えて

0

使用recipientListまたはtoDあなたがルートにしたい場合は、単一の動的宛先へのメッセージ - このFAQを参照してください。あなたは、空/ヌルで停止するよう指示するまでhttp://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

は、ダイナミックルータがルーティングを保つwhile loopのようなものです先。上部のドキュメント:http://camel.apache.org/dynamic-router.htmlを参照してください。そして、あなたの例は、そのハードコーディングされた目的地の価値としてそれをしません。

+0

あなたの答えはありがたいですが、動作しません。メッセージは 'jms:topic:urgent_doc1_prod1'にエンキューされますが、デキューされずにDLQで終了します。 – ggwtf

+0

質問はありません。あなたはJMS上で何らかの要求/応答をしていますが、続行する前にCamelが応答メッセージを待つようにします。 –

+0

私は、実行時にユーザーインターフェイスで動的ルートを作成し、動的部分を使用して、これらの動的ルートを介してメッセージを(要求で定義されたオプションに従って)転送します。最後に、処理中のメッセージ(最初のリクエストの内容を含む)を送信したいだけです。 – ggwtf

0

実際、それは私の誤解でした。私は、ダイナミックルーティングの後で、 "from"ルートを独立して宣言しなかったので、コンシューマーはいなかったのでタイムアウトしました。

@Override 
public void configure() throws Exception { 
    from(fromEndpoint).routeId(name + "a").recipientList(method(DynamicRoutingManager.class, "getRoute")); 

    from(toEndpoint).routeId(name + "b").process(exchange -> { 

     final List<?> soaList = exchange.getIn().getBody(List.class); 
     final String type = (String) soaList.get(0); 
     final Integer documentNumber = (Integer) soaList.get(1); 
     final Integer productionStepNumber = (Integer) soaList.get(2); 
     final String message = (String) soaList.get(3); 

     final String messageToSend = "Route ID=" + name + ", from=" + fromEndpoint + ", type=" + type 
       + ", document number=" + documentNumber + ", production step number" + productionStepNumber 
       + ", message=" + message; 

     LOG.debug("==> message={}", messageToSend); 
     exchange.getOut().setBody(messageToSend); 
    }); 
} 

です。

関連する問題