camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "raulvk.soa" <raulvk....@gmail.com>
Subject Re: XStream with JBI
Date Thu, 23 Oct 2008 11:48:11 GMT


XStream does not throw any exception (probably because it does its
processing well and it returns the generated object). However, the object
returned by XStream is not set as the IN message because it is not XML. When
iBATIS receives the message, it throws an exception because the Body is
NULL.

I have created the following test to illustrate this behaviour:


    	XStream xst = new XStream();
    	xst.alias("Person", Person.class);
    	XStreamDataFormat xstdf = new XStreamDataFormat();
    	xstdf.setXStream(xst);


    	from("jbi:service:http://www.mycompany.org/xstreamService")
    		.convertBodyTo(String.class).process(new Processor() {
	    			public void process(Exchange exchange) throws Exception {
	    				System.out.println("11111111-------------------->>>>>> " +
exchange.getIn());
	    				if (exchange.getIn() != null)
	    					System.out.println("::::: Body: " + exchange.getIn().getBody());
	    				else
	    					System.out.println("::::: Body IS NULL");
	    			}
	    		})
	    		.unmarshal(xstdf).process(new Processor() {
	    			public void process(Exchange exchange) throws Exception {
	    				System.out.println("22222222-------------------->>>>>> " +
exchange.getIn());
	    				if (exchange.getIn() != null)
	    					System.out.println("::::: Body: " + exchange.getIn().getBody());
	    				else
	    					System.out.println("::::: Body IS NULL");
	    			}
	    		})


Basically, this is what happens: 
   - before XStream --> the in message is of type NormalisedMessageImpl, and
the body is of type DOMSource.
   - after XStream --> the in message is of type NormalisedMessageImpl, and
the body is NULL.

Basically, a solution that comes to mind is to convert the JbiExchange to a
standard Camel Exchange... but where can I do this? I can't do this in a
Processor, because it wont allow me to SUBSTITUTE the exchange itself....

Any ideas?



Gert Vanthienen wrote:
> 
> L.S.,
> 
> What is the exception or error you are getting?  We should definitely 
> support this use case out-of-the-box...
> 
> Regards,
> 
> Gert
> 
> raulvk.soa wrote:
>> Hi,
>>
>> I am using Camel embedded in ServiceMix. My camel route receives a JBI
>> message, turns it into a Java Object by using XStream and then passes it
>> on
>> to iBATIS.
>>
>> However, I am facing problems with the XStream processing. I suspect that
>> these are derived from the fact that the underlying Camel Exchange is
>> actually a JbiExchange which only accepts XML as the in and out body
>> messages.
>>
>> Therefore, I need to get rid of all the Jbi stuff and simply use a
>> standard
>> Camel Exchange which will allow me to set an Object as the in message.
>>
>> Is it possible to do so out of the box?
>>
>> Thanks!
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/XStream-with-JBI-tp20129124s22882p20129325.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message