2016-11-18 5 views
0

私はラク1のラクダ交換のプロパティを設定しています。私はスプリッタの中の2番目のルートを同じものに更新しようとしています。スプリッタの2番目の反復では、新しい更新された値の代わりにルート1に設定した元の値を取得しています。キャメルの交換の性質を更新できません

public void setMyProperty(Exchange exchange) { 
      exchange.setProperty("testProp", "hello"); 
     } 

    public void setProperty(Exchange exchange) { 
      sysout(exchange.getProperty("testProp").toString())//this always prints "hello" 
      String x=exchange.getProperty("testProp")+some other value;// in all iterations of split I am getting 'hello' as the value of the property instead of new value 
      exchange.setProperty("testProp", x); 
      sysout(exchange.getProperty("testProp").toString())// this line prints the new value 
     } 

プロパティが更新されないのはなぜ:以下は私が...豆インサイド

<route handleFault="true" streamCache="true" id="route1"> 
<from uri="cxfrs://bean://test?synchronous=true"/> 
     <bean ref="testBean" method="setMyProperty"/>// setting initial value for property 
     <to uri="direct:directCall"/> 
</route> 

<route handleFault="true" streamCache="true" id="route2"> 
    <from uri="direct:directcall"/> 
    <log message="Inside Second call..."/> 
    <split> 
    <jsonpath>some Json path</jsonpath> 
     <bean ref="formatConvertor" method ="convertLHMToJSON(${body})"/> 

    <split> 
     <jsonpath>some json path</jsonpath> 
    <bean ref="PropertySetter" method ="setProperty"/> //I am setting new value in this method 
    </split> 
    </split> 

をしようとしているサンプルはありますか?私はヘッダーを設定しようとしました。同じ結果。ありがとうございました。

+0

なぜあなたは交換プロパティを設定するためにBeanを使用していますか?表示されている以上のロジックがない限り、.setProperty( "propertyName"、 "propertyValue");その後、分割内の同じコードを使用してプロパティを更新することができます。 –

+0

実際、私はプロパティに設定する前に、豆の中に多くの変換を持っています。再び分割の中で私はプロパティを更新する前にビジネスロジックを書く必要があります。 – Jay

+0

あなたが貼り付けたコードを処理できないのはなぜか分かりません。私は前に分割で交換プロパティを更新しています。簡単な例でテストすればよいと思います。 SplitIndexをexchangeプロパティに置き、その値を記録します。各分割中にそのプロパティを見ることができることを確認してください。 –

答えて

2

split-aggregateパターンを使用して、スプリットの繰り返しが発生するたびにソースメッセージから新しい交換が作成されるため、古い交換から新しい交換まで分割の各反復中にプロパティ値をコピーする必要がありますプロパティを持っている&分割前にヘッダーが設定されている) recover headers value after split apache camel

+0

ありがとうサガール。私の一日を救った。 – Jay

関連する問題