是否可以在骆驼路线中使用方法引用? :
from(X).bean(instance::method)
谢谢
答案 0 :(得分:0)
有两种方法可以执行此操作。如CookieSoup所述,您可以使用bean(Instance.class, "method(String)")
这样的bean binding。
或者您可以使用骆驼Processors和“变形”。 on github有一个使用方法的示例(您需要Camel 2.18.0或更高版本)。
class SomeClass {
public void method(String body) {
}
public String methodWithReturn(String body) {
return body;
}
}
.processor
.body(String.class, instance::method)
.translate
.body(String.class, instance::methodWithReturn)
请注意,processors是使用者,而transforms是返回转换后的消息正文的函数。