12

次のような Camel ルートがあるとします。

from("direct:myRoute")
        .setHeader("someHeader", simple("some header value"))
        .beanRef("myBean", "beanMethod");

そして、私は次のようなBeanを持っていますcannot change:

public class MyBean {
    public void beanMethod(String headerExpected) {
        // do something with the value here.
    }
}

基本的に、 myRoute から myBean 内の beanMethod に someHeader の渡したい思います

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?

4

2 に答える 2

25

次のように説明した方法でパラメーターを渡すことができます。

from("direct:myRoute")
.setHeader("someHeader", simple("some header value"))
.to("bean:myBean?method=beanMethod(${header.someHeader})")

Bean バインディングの他の方法を含む詳細情報は、http://camel.apache.org/bean-binding.htmlにあります。

于 2014-05-28T12:39:44.870 に答える