0
我在路由1中设置骆驼交换的属性。我试图在分离器内更新第二条路由。但在分离器的第二次迭代中,我获得了我在路由1中设置的原始值,而不是新的更新值。下面是我努力的样本..无法更新驼峰交换属性
<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>
豆内部:为什么不更新
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
}
的财产?即使我尝试设置标题。相同的结果。谢谢。
为什么使用bean设置交换属性?除非显示的逻辑更多,否则可以执行.setProperty(“propertyName”,“propertyValue”);然后,您可以在分割中使用相同的代码来更新属性。 –
其实,在设置属性之前,我在bean中有很多转换。再次在拆分我需要编写业务逻辑之前我更新属性。 – Jay
从粘贴的代码处理这个代码有点难,为什么它不起作用,我之前已经更新了split中的交换属性,并且工作正常。我认为如果你用一个简单的例子进行测试会更好。将SplitIndex放入交换属性中并记录该值。看到你可以在每次拆分过程中看到该属性。 –