You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Corneliu Chitic <co...@computaris.com.INVALID> on 2020/09/16 23:57:24 UTC

Unclear reasons for conversion rules when using Simple language

Hi,

Can you please help me understand the rules for Simple type conversion? I find the documentation a bit confusing and trials even more.
Running Apache Camel 3.4.3 with Spring Boot. I have a mixture of code written in XML DSL and Java.

The code snippet is:
...#1
<choice>
<when>
<simple>${header.CamelHttpResponseCode} != null &amp;&amp; ${header.CamelHttpResponseCode} != 200</simple>
...#2
<choice>
<when>
<simple>${header.CamelHttpResponseCode} == 504</simple>
...#3
<choice>
<when>
<simple>${header.retriesCount} > 0</simple>
...#4
exchange.setProperty("isError", isError); //isError is of primitive type boolean
<when>
<simple>${exchangeProperty.isError} == true</simple>

I have collected the following from the debug log:
...#1
20200916214720675 INFO  feCtx-22 Tracing [1600292411032-0-22162]      [serverResponse] [choice[when[simple{${header.Camel] Exchange[Id: ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165, ExchangePattern: InOnly, Headers: {authToken=password, breadcrumbId=ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22162, CamelHttpResponseCode=200, retriesCount=0}, BodyType: String]
20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.String with value: 200
20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
...#2
20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Integer with value: 504
20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
...#3
20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.Long with value: 0
20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Long with value: 0
20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
...#4
20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.Boolean -> java.lang.String with value: false
20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@9e2b199 to convert [class java.lang.Boolean=>class java.lang.String]
20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.String -> java.lang.Boolean with value: true
20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@54ee423f to convert [class java.lang.String=>class java.lang.Boolean]
20200916220541159 DEBUG pool-14-thread-1 FilterProcessor [1600292411032-0-121421] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-121421]

The documentation states that right value is converted to left value type (or both if no direct transition is possible). What I don't understand is:
1. Why is transitioning from Integer to String for CamelHttpResponseCode=200? Also the transition seems different compared to point #2 below although is checking same header.
2. Why is transitioning from String to Integer for CamelHttpResponseCode=504? Different than #1 above
3. Why is transitioning from Integer to Long for retriesCount (which is of type int and of value 0) and for String to Long for 0 (from the condition)?
4. Why the double transition of Left value from Boolean to String and of the right value from String to Boolean?

I want to avoid these transitions and reduce the processing time as much as possible.

Thank you, Corneliu
This email is subject to Computaris email terms of use: https://www.computaris.com/email-terms-use/

Re: Unclear reasons for conversion rules when using Simple language

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Okay so we have optimized this for Camel 3.6, thanks for bringing this
to our attention here in the Camel community

On Sun, Sep 20, 2020 at 9:53 AM Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi
>
> There is maybe some things that can be optmized a little bit
> https://issues.apache.org/jira/browse/CAMEL-14542
>
> However the rule of thumb is that type matching via simple language is
> more complex as both operators can be dynamic values, and also a
> numeric value such as 0, would that be a int, long, float, etc
> depending on the other value etc.
>
> And also mind that the simple language is entered as text and not a
> programming langauge
>
> On Thu, Sep 17, 2020 at 1:57 AM Corneliu Chitic
> <co...@computaris.com.invalid> wrote:
> >
> > Hi,
> >
> > Can you please help me understand the rules for Simple type conversion? I find the documentation a bit confusing and trials even more.
> > Running Apache Camel 3.4.3 with Spring Boot. I have a mixture of code written in XML DSL and Java.
> >
> > The code snippet is:
> > ...#1
> > <choice>
> > <when>
> > <simple>${header.CamelHttpResponseCode} != null &amp;&amp; ${header.CamelHttpResponseCode} != 200</simple>
> > ...#2
> > <choice>
> > <when>
> > <simple>${header.CamelHttpResponseCode} == 504</simple>
> > ...#3
> > <choice>
> > <when>
> > <simple>${header.retriesCount} > 0</simple>
> > ...#4
> > exchange.setProperty("isError", isError); //isError is of primitive type boolean
> > <when>
> > <simple>${exchangeProperty.isError} == true</simple>
> >
> > I have collected the following from the debug log:
> > ...#1
> > 20200916214720675 INFO  feCtx-22 Tracing [1600292411032-0-22162]      [serverResponse] [choice[when[simple{${header.Camel] Exchange[Id: ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165, ExchangePattern: InOnly, Headers: {authToken=password, breadcrumbId=ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22162, CamelHttpResponseCode=200, retriesCount=0}, BodyType: String]
> > 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.String with value: 200
> > 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> > ...#2
> > 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Integer with value: 504
> > 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> > ...#3
> > 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.Long with value: 0
> > 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Long with value: 0
> > 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> > ...#4
> > 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.Boolean -> java.lang.String with value: false
> > 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@9e2b199 to convert [class java.lang.Boolean=>class java.lang.String]
> > 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.String -> java.lang.Boolean with value: true
> > 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@54ee423f to convert [class java.lang.String=>class java.lang.Boolean]
> > 20200916220541159 DEBUG pool-14-thread-1 FilterProcessor [1600292411032-0-121421] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-121421]
> >
> > The documentation states that right value is converted to left value type (or both if no direct transition is possible). What I don't understand is:
> > 1. Why is transitioning from Integer to String for CamelHttpResponseCode=200? Also the transition seems different compared to point #2 below although is checking same header.
> > 2. Why is transitioning from String to Integer for CamelHttpResponseCode=504? Different than #1 above
> > 3. Why is transitioning from Integer to Long for retriesCount (which is of type int and of value 0) and for String to Long for 0 (from the condition)?
> > 4. Why the double transition of Left value from Boolean to String and of the right value from String to Boolean?
> >
> > I want to avoid these transitions and reduce the processing time as much as possible.
> >
> > Thank you, Corneliu
> > This email is subject to Computaris email terms of use: https://www.computaris.com/email-terms-use/
>
>
>
> --
> 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: Unclear reasons for conversion rules when using Simple language

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

There is maybe some things that can be optmized a little bit
https://issues.apache.org/jira/browse/CAMEL-14542

However the rule of thumb is that type matching via simple language is
more complex as both operators can be dynamic values, and also a
numeric value such as 0, would that be a int, long, float, etc
depending on the other value etc.

And also mind that the simple language is entered as text and not a
programming langauge

On Thu, Sep 17, 2020 at 1:57 AM Corneliu Chitic
<co...@computaris.com.invalid> wrote:
>
> Hi,
>
> Can you please help me understand the rules for Simple type conversion? I find the documentation a bit confusing and trials even more.
> Running Apache Camel 3.4.3 with Spring Boot. I have a mixture of code written in XML DSL and Java.
>
> The code snippet is:
> ...#1
> <choice>
> <when>
> <simple>${header.CamelHttpResponseCode} != null &amp;&amp; ${header.CamelHttpResponseCode} != 200</simple>
> ...#2
> <choice>
> <when>
> <simple>${header.CamelHttpResponseCode} == 504</simple>
> ...#3
> <choice>
> <when>
> <simple>${header.retriesCount} > 0</simple>
> ...#4
> exchange.setProperty("isError", isError); //isError is of primitive type boolean
> <when>
> <simple>${exchangeProperty.isError} == true</simple>
>
> I have collected the following from the debug log:
> ...#1
> 20200916214720675 INFO  feCtx-22 Tracing [1600292411032-0-22162]      [serverResponse] [choice[when[simple{${header.Camel] Exchange[Id: ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165, ExchangePattern: InOnly, Headers: {authToken=password, breadcrumbId=ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22162, CamelHttpResponseCode=200, retriesCount=0}, BodyType: String]
> 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.String with value: 200
> 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> ...#2
> 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Integer with value: 504
> 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> ...#3
> 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.Integer -> java.lang.Long with value: 0
> 20200916214720675 TRACE feCtx-22 CoreTypeConverterRegistry [1600292411032-0-22162] Finding type converter to convert java.lang.String -> java.lang.Long with value: 0
> 20200916214720675 DEBUG feCtx-22 FilterProcessor [1600292411032-0-22162] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-22165]
> ...#4
> 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.Boolean -> java.lang.String with value: false
> 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@9e2b199 to convert [class java.lang.Boolean=>class java.lang.String]
> 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Finding type converter to convert java.lang.String -> java.lang.Boolean with value: true
> 20200916220541159 TRACE pool-14-thread-1 CoreTypeConverterRegistry [1600292411032-0-121421] Using converter: org.apache.camel.support.SimpleTypeConverter@54ee423f to convert [class java.lang.String=>class java.lang.Boolean]
> 20200916220541159 DEBUG pool-14-thread-1 FilterProcessor [1600292411032-0-121421] Filter matches: false for exchange: Exchange[ID-CLSPCOYKHLOvWDSx-L-NK-X-00-FE-01-1600292411032-0-121421]
>
> The documentation states that right value is converted to left value type (or both if no direct transition is possible). What I don't understand is:
> 1. Why is transitioning from Integer to String for CamelHttpResponseCode=200? Also the transition seems different compared to point #2 below although is checking same header.
> 2. Why is transitioning from String to Integer for CamelHttpResponseCode=504? Different than #1 above
> 3. Why is transitioning from Integer to Long for retriesCount (which is of type int and of value 0) and for String to Long for 0 (from the condition)?
> 4. Why the double transition of Left value from Boolean to String and of the right value from String to Boolean?
>
> I want to avoid these transitions and reduce the processing time as much as possible.
>
> Thank you, Corneliu
> This email is subject to Computaris email terms of use: https://www.computaris.com/email-terms-use/



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