You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "raulvk.soa" <ra...@gmail.com> on 2008/10/23 13:33:21 UTC

XStream with JBI

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!
-- 
View this message in context: http://www.nabble.com/XStream-with-JBI-tp20129124s22882p20129124.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: XStream with JBI

Posted by Gert Vanthienen <ge...@skynet.be>.
Raul,

Just committed a fix for this issue.  Could you try building a -SNAPSHOT 
of the servicemix-camel component locally to ensure that this works for 
you? 

Thanks,

Gert

raulvk.soa wrote:
> There you go: https://issues.apache.org/activemq/browse/SM-1654.
>
> Is there really a necessity the servicemix-camel component puts the exchange
> in a specific JbiExchange? Can't we just use a generic Exchange, and place
> the limitation of XML messages only at the component? This way, the XML
> limitation would be eliminated. The JBI component should throw an exception
> if it receives a message (from within Camel, obviously) that contains
> non-XML content.
>
> Could this be a feasible solution?
>
>
>
> Gert Vanthienen wrote:
>   
>> L.S.,
>>
>> Could you open a JIRA issue for this on the servicemix-camel component?  
>> This use case should be supported without having to do any intermediate 
>> processing -- even though the original JBI Message uses XML, there's no 
>> reason why the payload has to remain an XML document once you're inside 
>> Camel.  We should get this to work with a simple 
>> from("jbi:..").unmarshal().to("ibatis:...").
>>
>> Thanks,
>>
>> Gert
>>
>> raulvk.soa wrote:
>>     
>>> 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
>>>>
>>>>     
>>>>         
>>>   
>>>       
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://gertvanthienen.blogspot.com
>>
>>     
>
>   


Re: XStream with JBI

Posted by Gert Vanthienen <ge...@skynet.be>.
Raul,

By using a JbiExchange, we can avoid copying body/properties/attachments 
when using Camel as a pure mediation router component inside 
ServiceMix.  If you just going to route the message contents, there's no 
need to create another object and copy all the information from the JBI 
MessageExchange to the Camel Exchange.  I'd rather suggest we make the 
setBody() method on the Exchange a bit more intelligent to store new 
values in the Camel Message and only propagate the change to the 
NormalizedMessage when possible.  Since you obviously know your way 
around in the codebase, do you fancy taking a stab at a patch for this?

Regards,

Gert

raulvk.soa wrote:
> There you go: https://issues.apache.org/activemq/browse/SM-1654.
>
> Is there really a necessity the servicemix-camel component puts the exchange
> in a specific JbiExchange? Can't we just use a generic Exchange, and place
> the limitation of XML messages only at the component? This way, the XML
> limitation would be eliminated. The JBI component should throw an exception
> if it receives a message (from within Camel, obviously) that contains
> non-XML content.
>
> Could this be a feasible solution?
>
>
>
> Gert Vanthienen wrote:
>   
>> L.S.,
>>
>> Could you open a JIRA issue for this on the servicemix-camel component?  
>> This use case should be supported without having to do any intermediate 
>> processing -- even though the original JBI Message uses XML, there's no 
>> reason why the payload has to remain an XML document once you're inside 
>> Camel.  We should get this to work with a simple 
>> from("jbi:..").unmarshal().to("ibatis:...").
>>
>> Thanks,
>>
>> Gert
>>
>> raulvk.soa wrote:
>>     
>>> 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
>>>>
>>>>     
>>>>         
>>>   
>>>       
>>
>> -----
>> ---
>> Gert Vanthienen
>> http://gertvanthienen.blogspot.com
>>
>>     
>
>   


Re: XStream with JBI

Posted by "raulvk.soa" <ra...@gmail.com>.

There you go: https://issues.apache.org/activemq/browse/SM-1654.

Is there really a necessity the servicemix-camel component puts the exchange
in a specific JbiExchange? Can't we just use a generic Exchange, and place
the limitation of XML messages only at the component? This way, the XML
limitation would be eliminated. The JBI component should throw an exception
if it receives a message (from within Camel, obviously) that contains
non-XML content.

Could this be a feasible solution?



Gert Vanthienen wrote:
> 
> L.S.,
> 
> Could you open a JIRA issue for this on the servicemix-camel component?  
> This use case should be supported without having to do any intermediate 
> processing -- even though the original JBI Message uses XML, there's no 
> reason why the payload has to remain an XML document once you're inside 
> Camel.  We should get this to work with a simple 
> from("jbi:..").unmarshal().to("ibatis:...").
> 
> Thanks,
> 
> Gert
> 
> raulvk.soa wrote:
>> 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
>>>
>>>     
>>
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

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


Re: XStream with JBI

Posted by Gert Vanthienen <ge...@skynet.be>.
L.S.,

Could you open a JIRA issue for this on the servicemix-camel component?  
This use case should be supported without having to do any intermediate 
processing -- even though the original JBI Message uses XML, there's no 
reason why the payload has to remain an XML document once you're inside 
Camel.  We should get this to work with a simple 
from("jbi:..").unmarshal().to("ibatis:...").

Thanks,

Gert

raulvk.soa wrote:
> 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
>>
>>     
>
>   


RE: XStream with JBI

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Yeah use a BEAN and send the body using ProducerTemplate, then it really should be a new exchange.


>     	from("jbi:service:http://www.mycompany.org/xstreamService")
>     		.convertBodyTo(String.class).to("bean:myBean")


You then configure myBean in the registry (eg spring xml)

<bean id="myBean" class="..."/>

If you don't know how to get a ProducerTemplate injected then see for instance the AXIS tutorial:
http://activemq.apache.org/camel/tutorial-axis-camel.html


You can also use annotations to get it injected

And in MyBean

  public void doSomething(String body) {
    ...
    producer.sendBody("seda:foo", body);
  }


Or use Exchange as the parameter and get the camel context from that one and invoke createProducerTemplate

  public void doSomething(Exchange exchange) {
     exchanage.getCamelContext().createProducerTeamplate()
  


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 23. oktober 2008 14:23
To: camel-user@activemq.apache.org
Subject: RE: XStream with JBI



Hi Claus,

Just tried it and it still continues being a JbiMessage with a
NormalisedMessageImpl objects as the in message.

Any other ideas?


Claus Ibsen wrote:
> 
> Hi
> 
> You can send the jbi stuff to a seda queue, and then poll the seda queue
> in a 2nd route. Then it should be a new Exchange and a Camel exchange as a
> org.apache.camel.impl.DefaultExchange object.
> 
> 
>     	from("jbi:service:http://www.mycompany.org/xstreamService")
>     		.convertBodyTo(String.class).to("seda:foo")
> 
>       From("seda:foo")...
> 
>  
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
> Sent: 23. oktober 2008 13:48
> To: camel-user@activemq.apache.org
> Subject: Re: XStream with JBI
> 
> 
> 
> 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.
> 
> 
> 

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


RE: XStream with JBI

Posted by "raulvk.soa" <ra...@gmail.com>.

Hi Claus,

Just tried it and it still continues being a JbiMessage with a
NormalisedMessageImpl objects as the in message.

Any other ideas?


Claus Ibsen wrote:
> 
> Hi
> 
> You can send the jbi stuff to a seda queue, and then poll the seda queue
> in a 2nd route. Then it should be a new Exchange and a Camel exchange as a
> org.apache.camel.impl.DefaultExchange object.
> 
> 
>     	from("jbi:service:http://www.mycompany.org/xstreamService")
>     		.convertBodyTo(String.class).to("seda:foo")
> 
>       From("seda:foo")...
> 
>  
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
> Sent: 23. oktober 2008 13:48
> To: camel-user@activemq.apache.org
> Subject: Re: XStream with JBI
> 
> 
> 
> 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.
> 
> 
> 

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


RE: XStream with JBI

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You can send the jbi stuff to a seda queue, and then poll the seda queue in a 2nd route. Then it should be a new Exchange and a Camel exchange as a org.apache.camel.impl.DefaultExchange object.


    	from("jbi:service:http://www.mycompany.org/xstreamService")
    		.convertBodyTo(String.class).to("seda:foo")

      From("seda:foo")...

 

Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: raulvk.soa [mailto:raulvk.soa@gmail.com] 
Sent: 23. oktober 2008 13:48
To: camel-user@activemq.apache.org
Subject: Re: XStream with JBI



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.


Re: XStream with JBI

Posted by "raulvk.soa" <ra...@gmail.com>.

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.


RE: XStream with JBI

Posted by "raulvk.soa" <ra...@gmail.com>.
Hi Claus,

As you said, I don't think that issue is related to this one. I think my
issue is specific to the way JBI exchanges are handled within Camel...



Claus Ibsen wrote:
> 
> Hi
> 
> This might not at all be related, but beware that Vadim had some really
> strange issues with xstream. He had to set some kind of file encoding with
> -D to the JVM to get it working.
> 
> http://issues.apache.org/activemq/browse/CAMEL-924
> 
> But I don't think he used JBI though.
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: Gert Vanthienen [mailto:gert.vanthienen@skynet.be] 
> Sent: 23. oktober 2008 13:37
> To: camel-user@activemq.apache.org
> Subject: Re: XStream with JBI
> 
> 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!
>>   
> 
> 
> 

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


RE: XStream with JBI

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

This might not at all be related, but beware that Vadim had some really strange issues with xstream. He had to set some kind of file encoding with -D to the JVM to get it working.

http://issues.apache.org/activemq/browse/CAMEL-924

But I don't think he used JBI though.


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Gert Vanthienen [mailto:gert.vanthienen@skynet.be] 
Sent: 23. oktober 2008 13:37
To: camel-user@activemq.apache.org
Subject: Re: XStream with JBI

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!
>   


Re: XStream with JBI

Posted by Gert Vanthienen <ge...@skynet.be>.
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!
>