Gert,
You are right. I needed to use convertBodyTo(String.class) to avoid the
streams to get closed. I added this instruction after and before the
transformation route.
from("jetty:http://localhost:9080/research_msp/VirtualService")
.convertBodyTo(java.lang.String.class)
.process(new SOAPRequestTransformProcessor())
.convertBodyTo(java.lang.String.class)
.to("log:IN")
.choice()
.when(isDocumentRequest)
.to("log:DOCUMENT_REQUEST")
.to("jbi:service:http://path.to.service/ServiceName1//ServiceName2WSDL")
.when(isVersionRequest)
.to("log:VERSION_REQUEST")
.to("jbi:service:http://path.to.service/ServiceName2//ServiceName2WSDL")
.when(isLiferayRequest)
.to("log:LIFERAY_REQUEST")
.to("jbi:service:http://path.to.service/ServiceName3//ServiceName2WSDL")
.otherwise()
.to("log:NOT_SUPPORTED")
.throwFault(new IllegalArgumentException("The requested
operation is not
supported."))
.end();
- Before because this way I don't need to cast the body to an InputStream
and then transform it to a String (I use a POJO for transformation).
- After because multiple routes and predicates read the message after its
transformed (and because I can put back my log routes).
Right now I can send the JBI messages to the correct CXF BCs. I need to
figure out how to get response back from them synchronously... but that's
another story.
Thanks to everyone for your help!
Regards,
Angel
Gert Vanthienen wrote:
>
> L.S.,
>
> This is probably being caused by a stream-based message that is being
> sent into the router. In ServiceMix, we prefer using streams wherever
> possible because it dramatically improves esb throughput. There's one
> drawback however: a stream can only be read once.
>
> Before you added the content-based router logic, your Camel route
> wasn't reading the stream so the message stream was arriving at the
> cxf bc provider endpoint unread. Now, with the content-based router,
> the Camel route reads the stream to determine where to route the
> message. Camel has a feature called stream caching
> (http://camel.apache.org/stream-caching.html) to handle these use
> cases. If you enable this feature on your routes, the stream will be
> read and cached before starting the processing. Another way to solve
> this is by adding a convertBody(String.class) right after the from()
> method call, to ensure we're sending a String instead of a stream.
>
> For Camel 2.x and ServiceMix 4.1, we plan to move this logic into the
> servicemix-camel endpoint, so it will automatically convert to a
> re-readable type unless you explicitly tell it to keep the stream --
> for now though, you'll have to go with one of the two workarounds I
> mentioned before.
>
> Regards,
>
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
>
>
--
View this message in context:
http://www.nabble.com/Web-Services-Virtualization-using-ServiceMix-tp25514386p25617494.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.