-1

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

rocky
  • 753
  • 2
  • 10
  • 26

2 Answers2

1

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} )");
Screwtape
  • 1,337
  • 2
  • 12
  • 27
0

you should be able to put the instance variable onto the exchange as a header and then access it from the Exchange object in your your bean. Camel will automatically bind the Exchange to a bean if you simply add an Exchange parameter to your bean method, as described here in the camel docs.

eg:

class CamelBean {
    public String getBatchContent(String body, Exchange exchange) {
        ByteArrayOutputStream stream = exchange.getHeader("stream");
    }       
}
stringy05
  • 6,511
  • 32
  • 38