Search code examples
apache-camelspring-camel

How to pass value of instance variable of route to another bean in camel


I have sample route like below and need to send value of outputStream to batchContentProcessor class to getBatchConent method..something like below..help me how to send instance variable value to method of bean


Solution

  • I'm not sure what you're trying to achieve, and I suspect that understanding that would give me a better chance of giving you a good answer.

    Your java DSL won't work because you are trying to add the "string" value of outputStream to the URL which won't do anything useful - it'll just make the URL invalid.

    Read the bean-binding instructions for how the bean calling process works: http://camel.apache.org/bean-binding.html

    Since you've already assigned your stream to the stream header, I think you could do..

        from(DECRYPTION_ENDPOINT).routeId(CcsRoutes.DECRYPTION_ROUTE.name())
         .setHeader("stream", constant(outputStream)).log("About to write ${file:name}")
         .to("bean:batchContentProcessor?method=getBatchConent( ${header.stream} )");