You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yxzhao <yx...@stonewain.com> on 2016/10/20 19:47:31 UTC

Body Object in Camel Exchange

We have a camel route which uses the length of exchange message body to
determine data types. It works fine when the body contains a string or array
of objects, but if it contains array of primitive types, it only returns 1
as length. Below is a simplified version of the route:

 <route id="oceanview-test-body">
	<from uri="timer://test?fixedRate=true&amp;period=10000"/>
	<to uri="bean:utilBean?method=setDataInbody"/>
	<log loggingLevel="INFO" message="test data class ${body.class.name},
length [${body.length}]" logName="TEST"/>
 </route>

I tried to set String, array of Strings, byte, int and Integer in method
setDataInBody, the result from String, array of String and Integer are
correct. For array of int and byte it always shows 1 as body.length.

Does anyone know why arrays of primitive types don't return correct array
length in camel exchange body?

Thanks in advance!





--
View this message in context: http://camel.465427.n5.nabble.com/Body-Object-in-Camel-Exchange-tp5789051.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Body Object in Camel Exchange

Posted by yxzhao <yx...@stonewain.com>.
Sorry I have not checked this thread.

Thanks for your reply. We're not using the latest Camel version, but 2.14.2.
Based on what CAMEL-6481 describes and the fixed time, version 2.14.2 should
not have this problem anymore. However, it does happen.

We changed our config to go around as of now. Hope it can be resolved with
later versions.



--
View this message in context: http://camel.465427.n5.nabble.com/Body-Object-in-Camel-Exchange-tp5789051p5792340.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Body Object in Camel Exchange

Posted by Claus Ibsen <cl...@gmail.com>.
You may use an old version of Camel as we fixed this in CAMEL-6481.

And I just added an unit test to test the int[].
https://github.com/apache/camel/commit/f554c483effb3342dde7ffcd04cf063f2e9887f8

On Sat, Oct 29, 2016 at 1:15 PM, Claus Ibsen <cl...@gmail.com> wrote:
> What version of Camel do you use?
>
> On Thu, Oct 20, 2016 at 9:47 PM, yxzhao <yx...@stonewain.com> wrote:
>> We have a camel route which uses the length of exchange message body to
>> determine data types. It works fine when the body contains a string or array
>> of objects, but if it contains array of primitive types, it only returns 1
>> as length. Below is a simplified version of the route:
>>
>>  <route id="oceanview-test-body">
>>         <from uri="timer://test?fixedRate=true&amp;period=10000"/>
>>         <to uri="bean:utilBean?method=setDataInbody"/>
>>         <log loggingLevel="INFO" message="test data class ${body.class.name},
>> length [${body.length}]" logName="TEST"/>
>>  </route>
>>
>> I tried to set String, array of Strings, byte, int and Integer in method
>> setDataInBody, the result from String, array of String and Integer are
>> correct. For array of int and byte it always shows 1 as body.length.
>>
>> Does anyone know why arrays of primitive types don't return correct array
>> length in camel exchange body?
>>
>> Thanks in advance!
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Body-Object-in-Camel-Exchange-tp5789051.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Body Object in Camel Exchange

Posted by Claus Ibsen <cl...@gmail.com>.
What version of Camel do you use?

On Thu, Oct 20, 2016 at 9:47 PM, yxzhao <yx...@stonewain.com> wrote:
> We have a camel route which uses the length of exchange message body to
> determine data types. It works fine when the body contains a string or array
> of objects, but if it contains array of primitive types, it only returns 1
> as length. Below is a simplified version of the route:
>
>  <route id="oceanview-test-body">
>         <from uri="timer://test?fixedRate=true&amp;period=10000"/>
>         <to uri="bean:utilBean?method=setDataInbody"/>
>         <log loggingLevel="INFO" message="test data class ${body.class.name},
> length [${body.length}]" logName="TEST"/>
>  </route>
>
> I tried to set String, array of Strings, byte, int and Integer in method
> setDataInBody, the result from String, array of String and Integer are
> correct. For array of int and byte it always shows 1 as body.length.
>
> Does anyone know why arrays of primitive types don't return correct array
> length in camel exchange body?
>
> Thanks in advance!
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Body-Object-in-Camel-Exchange-tp5789051.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2