Search code examples
apache-cameljbossfuse

Camel Component: setting a Property dynamically from a Bean



I have defined a Camel Route in a Jboss Fuse BluePrint. I'd need to set one variable at runtime from a Bean. See this example:

<camelContext xmlns="http://camel.apache.org/schema/spring">
     <route id="wsClient">
            <from uri="timer:foo?repeatCount=1" />
            <setBody>
                <simple>Message</simple>
            </setBody>
            <transform>
                  <method bean="myBean" method="transform" />
            </transform>
            <to uri="cxf:bean:MyWebService?defaultOperationName={{operation}}" />
            <to uri="mock:result" />
     </route>
</camelContext>

In this example, I'd like to set the property named "operation" within the bean "myBean". Is it possible to do it? Thanks!


Solution

  • Yes, it is possible. First, set a header from the bean and later use http://camel.apache.org/recipient-list.html

    I am not familiar with Spring DSL, but in Java DSL it would look like this:

    .recipientList(simple("cxf:bean:MyWebService?defaultOperationName=${header.operation}"))