骆驼 - 从传递路线的具体参数为一个通用的bean方法 [英] Camel - Passing specific parameters from routes to a generic bean method
本文介绍了骆驼 - 从传递路线的具体参数为一个通用的bean方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我有一个骆驼的路线,看起来像这样:
Let's say I have a Camel route that looks like this :
from("direct:myRoute")
.setHeader("someHeader", simple("some header value"))
.beanRef("myBean", "beanMethod");
和我有一个bean不能更改
,看起来像这样:
And I have a bean that I cannot change
that looks like this :
public class MyBean {
public void beanMethod(String headerExpected) {
// do something with the value here.
}
}
基本上,我想传递的值 someHeader 从 myRoute 为 beanMethod 在 MyBean
明知beanMethod可以接受字符串
,我怎么能传递头的值 someHeader 往返航线,使其接受在一个字符串中的 beanMethod
Knowing that beanMethod can accept a String
, how can I pass the value of the header someHeader from the route so that it is accepted as a String within beanMethod?
推荐答案
您可以在您这样描述的方式传递参数:
You can pass parameters in the way you described like this:
from("direct:myRoute")
.setHeader("someHeader", simple("some header value"))
.to("bean:myBean?method=beanMethod(${header.someHeader})")
更多信息,包括其他方法结合豆可以在这里找到 http://camel.apache.org/bean- binding.html
这篇关于骆驼 - 从传递路线的具体参数为一个通用的bean方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文