According to the Camel Stream docs, it is possible to route message to/from various data streams.
However, in my case, I want the data (byte[]
) in a ByteArrayInputStream
to get sent off to a Camel route. The problem is that the only InputStream
that component seems to support is FileInputStream
like so:
from("stream:file?fileName=/server/logs/server.log&scanStream=true&scanStreamDelay=1000").to("bean:logService?method=parseLogLine");
But it looks like the only way to specify a ByteArrayInputStream
is to use the stream:header
URI like so:
ByteArrayInputStream byteStream = new ByteArrayInputStream(someData);
from("direct:a").setHeader("stream", constant(byteStream)).to("stream:header");
But if you have to specify the custom stream as a header, I don't see how you could accomplish such a thing inside the from()
clause. Any ideas how to do this?
stream:file
is for read files as a stream. You cannot send a java object to that endpoint. It only reads from files from your file system.
You can use Camel's type converter to convert the payload to something else, such as a byte[]
from("stream:file:...")
.convertBodyTo(byte[].class)
...
You can read about Camel's type converter here: http://camel.apache.org/type-converter.html