質問:incrementable指標を得ることができる方法 - すなわち、RouteBuilderのループ()中に使用する - そのために反復呼び出し「ダイレクト:thingC」意志(配列リストで)「プロセス」以降の要素? :-(...RouteBuilderのループ()中にインクリメンタルインデックスを取得するにはどうしたらいいですか?
:ここは
private final org.apache.camel.Processor proc1 = new Processor1();
private static final List<String> searchList = Arrays.asList("AA", "BB");
private static final int z = searchList.size();
private static int x = 0;
//***idea is to both elements using an index during the "loop".... Not working....
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&period=" + 5000) //5 seconds...
.to("direct:thingB");
from("direct:thingB")
.log("---------------------- (from(\"direct:thingB\"))... ----------x=" + x)
.loop(searchList.size()).to("direct:thingC");
from("direct:thingC")
.log("---------------------- (from(\"direct:thingC\"))... ----------searchList.get(" + x++ + ")=" + searchList.get(x));
}
ログ出力は(常に同じ要素を選択し、インデックスがインクリメントされません)このようになります...のconfigure()メソッドであります
2017-09-01 16:13:19,142 | INFO | 43 - timer://foo | route15 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingB"))... ----------x=0 2017-09-01 16:13:19,142 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=BB 2017-09-01 16:13:19,143 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=BB 2017-09-01 16:13:24,141 | INFO | 43 - timer://foo | route15 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingB"))... ----------x=0 2017-09-01 16:13:24,141 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=BB 2017-09-01 16:13:24,142 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=BB
目的は、このような出力を-instead-とすることです。
2017-09-01 16:13:19,142 | INFO | 43 - timer://foo | route15 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingB"))... ----------x=0
2017-09-01 16:13:19,142 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=AA
2017-09-01 16:13:19,143 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(1)=BB
2017-09-01 16:13:24,141 | INFO | 43 - timer://foo | route15 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingB"))... ----------x=0
2017-09-01 16:13:24,141 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(0)=AA
2017-09-01 16:13:24,142 | INFO | 43 - timer://foo | route16 | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | ---------------------- (from("direct:thingC"))... ----------searchList.get(1)=BB
ソリューション:アレッサンドロさんの提案どおり、以下は
private final String s = "AA,BB";
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&period=" + 5000) //5 seconds...
.setBody(constant(s))
.to("direct:thingB")
from("direct:thingB")
.split().tokenize(",")
.to("direct:thingC");
from("direct:thingC")
.log("body=" + body()); //note: this value looks like simple{AA}
}
アレッサンドロありがとうございます。上記の "split()"関数の使用に変更を加えました。ところで、私はどのように "AA"文字列を "simple {AA}"式から抽出するのですか?もう一度! – sairn