You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by boday <bo...@vektrel.com> on 2009/06/23 19:02:55 UTC

error when switching Camel route from to() to multicast()

environment: windows, jdk1.6, Eclipse 3.4, SMX3.3, Camel 1.4

here is my camel route...pulls XML messages from a JMS topic, decodes them,
filters them, routes to a persister and outbound JMS topic...

    	from("jbi:service:http://test.com/eda/mpPipeline")
    		.to("jbi:service:http://test.com/eda/messageDecoder?mep=in-out")
    		.choice()
    			.when().xpath("count(//InboundMessage) = 1")
    				   .multicast()
    				   		.to("jbi:service:http://test.com/messagePersister?mep=in");
    						.to("jbi:service:http://test.com/portalJMSService?mep=in");

here is the code from my servicemix-bean service unit class...it worked fine
before I added the multicast() to send to 2 destinations...

NormalizedMessage in = exchange.getMessage("in");
StringSource s = (StringSource) in.getContent();

and the error...

java.lang.ClassCastException:
org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache
cannot be cast to org.apache.servicemix.jbi.jaxp.StringSource

Clearly, the in.getContent() is returning a different Source class, but I'm
confused by the StreamCacheConverter$StreamSourceCache class.  I don't even
have this class in my Camel service unit (generated from maven)...why?  I
guess I can go find a JAR file that contains this and add it in...I'm just
confused why I have to do all this just to use a different Camel API?

Overall, I'm confused why the in.getContent() returns different Source
instances when the inbound data  format hasn't changed at all...this has
caught me several times already.  The strangest of which was when I turned
on JMS debugging and my Source went from a StreamSource to a DOMSource. 
Currently, I have instanceof conditionals to handle all the cases...is there
a better approach to handling this?

thanks






-- 
View this message in context: http://www.nabble.com/error-when-switching-Camel-route-from-to%28%29-to-multicast%28%29-tp24167728p24167728.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: error when switching Camel route from to() to multicast()

Posted by boday <bo...@vektrel.com>.
UPDATE:

I was able to get this working by adding .convertBodyTo(DOMSource.class) in
between my .to() and .choice() statements.  

This lets my avoid having to deal with the
StreamCacheConverter$StreamSourceCache format altogether.  It isn't ideal
because I'm not sure what the overhead is of converting messages, but it'll
work for now.

If anyone know of a better solution to this...please let me know.

thanks
-- 
View this message in context: http://www.nabble.com/error-when-switching-Camel-route-from-to%28%29-to-multicast%28%29-tp24167728p24176743.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.