Is there a way to set message headers from a bean?

前端 未结 3 1659
醉酒成梦
醉酒成梦 2021-02-08 23:14

I have a simple camel route I need to modify. The route looks like this:

from(source.uri)
    .unmarshal()
    .bean(TransformMessageBean.class, \"SomeMethod\")
         


        
相关标签:
3条回答
  • 2021-02-08 23:27

    Another way in XML:

    <setHeader name="headerName"> 
        <simple>${bean:yourBean.getMethod}</simple>           
    </setHeader>
    
    0 讨论(0)
  • 2021-02-08 23:34

    In Spring XML DSL, it would be something like

     <setHeader headerName="headerName">
          <method bean="mybean" method="mymethod" />                
    </setHeader>
    
    0 讨论(0)
  • 2021-02-08 23:42

    Certainly! One of the options available is

    .setHeader("headerName").method(beanInstance, "methodToGetHeaderValue")
    

    Using this approach, the method (say, methodToGetHeaderValue) on the provided bean instance will return a value, and that will become the value of the header.

    There are a number of options available. You can call it with a bean instance, a bean class (like in your example), or even a bean name, all with or without a method name.

    0 讨论(0)
提交回复
热议问题