Char,

Essentially, the from().streamCaching().... is the same thing as the .intercept you're using, so both of them should work. What version of ServiceMix are you using?

Could you try adding a to("log:stream?showBody=false&showBodyType=true") at the beginning and end of your route so we can figure out if any conversion is going on at all? What JBI component is sending the message into the route in the first place? Could you try enabling DEBUG logging in ServiceMix : DEBUG logging in ServiceMix will convert a StreamSource into a DOMSource as well, so the problem should disappear if we turn that on (just to ensure we are looking at the right problem here, we do want to solve this without DEBUG logging ;).

Putting the intercept at the beginning of your route, like you're doing is fine! Once the stream caching is working property, you should be able to get the body contents any way you like, because you would always be starting from the cached stream (regardless of the type you specify in the getBody()). FWIW: For the new servicemix-camel based on Camel 1.5, stream caching should be happening automatically when a message is obviously going to be read multiple times (like e.g. with a multicast)


Regards,

Gert


Char wrote:
Hi camel rider-community!

I have a question referring the usage of StreamCachingInterceptor.

My route-config (simplified):

from("jbi:endpoint:http://biz.accelsis.swm/InboundRoutingService/EDIFileInEndpoint";)
        .intercept(new StreamCachingInterceptor())
        .process(new DataProcessor(new SyntaxCheckProcessor(),
DataProcessor.BODY_TO_BODY))
        .multicast()
        .to("direct:ctrl", "direct:main");

        from("direct:ctrl")
        .intercept(new StreamCachingInterceptor())
        .process(new DataProcessor(new
ExtractionProcessor("/envelope/control/data"))
        .to("jbi:endpoint:http://biz.accelsis.swm/FileOutService/ContrlOut";);

        from("direct:main")
        .to("jbi:endpoint:http://biz.accelsis.swm/FileOutService/SapOut";);

I believe that i need the StreamCachingInterceptor because i send a message
containing a stream-body via multicast to two endpoints. My tests show that
if the first one (direct:ctrl) reads the message, the stream is used and can
not be read again by endpoint two (direct:main). But somehow, i tried
multiple tests with the StreamCachingInterceptor, but none of them is
working.

- Where do i have to insert ".intercept(new StreamCachingInterceptor())" ?

- How do i have to extract the body in the following Processor? The current
code is like this:
       ByteArrayInputStream is =
messageIn.getBody(StreamSource.class).getInputStream();
  Does that work?

I already tried a global "streamCaching()" and more local
from(...).streamCaching().to... alternatives, but i feel that i am missing
something.

Please help me. Thanks in advance.


Reply via email to