You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by garrydias <ga...@gmail.com> on 2011/08/19 23:09:52 UTC

Choice always return turn in first test

Hi folks
it´s my scenario?:

My body message is an instance of: 
*package foo;
public class MyMessageObject
{
    private Map&lt;String, Serializable&gt; property;
    // setter & gettter
    public String toString(){ return "toString called";}
}*

My xml is:
<bean id="wireTapMock" class="bar.RoutingSpy"/>
<camel:camelContext id="camelContext">
        <camel:endpoint id="endpointFileThen" uri="file://c:/dev/camel_then"
/>
	<camel:endpoint id="endpointFileOtherwise"
uri="file://c:/dev/camel_otherwise" />
        <camel:route id="rout1">        
            <camel:from ref="whatever" />
            <camel:convertBodyTo type="foo.MyMessageObject" />
            <camel:wireTap uri="bean:wireTapMock?method=execute"/>
            <camel:choice>
	            <camel:when>
	                <camel:simple>${in.body.property['key']} == 'not
garrydias'</camel:simple>
	        	<camel:convertBodyTo type="java.lang.String" />
	                <camel:to ref="endpointFileThen"/>
	            </camel:when>
		    <camel:otherwise>
	        	<camel:convertBodyTo type="java.lang.String" />
	                <camel:to uri="endpointFileOtherwise" />
		    </camel:otherwise>
	    </camel:choice>
      </camel:route>
</camel:context>

wt hell my wire tap RoutingSpy.execute logs the MyMessageObject.property
value as {key=garrydias} but the choice never goes to otherwise?

I already tried:
- invert the order in the logical test to force the cast of Serializable to
String: 
'not garrydias' == ${in.body.property['key']}
- create a setHeader with ${in.body.property['key']} value an try
<camel:simple>${in.header == 'not garrydias'</camel:simple>
- cut off the single quotes
<camel:simple>${in.body.property[key]} == 'not garrydias'</camel:simple>

But wasn t solved

I appreciate any help

--
View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-turn-in-first-test-tp4717029p4717029.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice always return turn in first test

Posted by Taariq Levack <ta...@gmail.com>.
Ah, mine didn't work until I added end, but I used java config not spring.

On Sat, Aug 20, 2011 at 8:07 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Try without the quotes in the key
>                         <camel:simple>${in.body.property[key]} == 'not
> garrydias'</camel:simple>
>
>
>
> On Fri, Aug 19, 2011 at 11:09 PM, garrydias <ga...@gmail.com> wrote:
> > Hi folks
> > it´s my scenario?:
> >
> > My body message is an instance of:
> > *package foo;
> > public class MyMessageObject
> > {
> >    private Map&lt;String, Serializable&gt; property;
> >    // setter & gettter
> >    public String toString(){ return "toString called";}
> > }*
> >
> > My xml is:
> > <bean id="wireTapMock" class="bar.RoutingSpy"/>
> > <camel:camelContext id="camelContext">
> >        <camel:endpoint id="endpointFileThen"
> uri="file://c:/dev/camel_then"
> > />
> >        <camel:endpoint id="endpointFileOtherwise"
> > uri="file://c:/dev/camel_otherwise" />
> >        <camel:route id="rout1">
> >            <camel:from ref="whatever" />
> >            <camel:convertBodyTo type="foo.MyMessageObject" />
> >            <camel:wireTap uri="bean:wireTapMock?method=execute"/>
> >            <camel:choice>
> >                    <camel:when>
> >                        <camel:simple>${in.body.property['key']} == 'not
> > garrydias'</camel:simple>
> >                        <camel:convertBodyTo type="java.lang.String" />
> >                        <camel:to ref="endpointFileThen"/>
> >                    </camel:when>
> >                    <camel:otherwise>
> >                        <camel:convertBodyTo type="java.lang.String" />
> >                        <camel:to uri="endpointFileOtherwise" />
> >                    </camel:otherwise>
> >            </camel:choice>
> >      </camel:route>
> > </camel:context>
> >
> > wt hell my wire tap RoutingSpy.execute logs the MyMessageObject.property
> > value as {key=garrydias} but the choice never goes to otherwise?
> >
> > I already tried:
> > - invert the order in the logical test to force the cast of Serializable
> to
> > String:
> > 'not garrydias' == ${in.body.property['key']}
> > - create a setHeader with ${in.body.property['key']} value an try
> > <camel:simple>${in.header == 'not garrydias'</camel:simple>
> > - cut off the single quotes
> > <camel:simple>${in.body.property[key]} == 'not garrydias'</camel:simple>
> >
> > But wasn t solved
> >
> > I appreciate any help
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Choice-always-return-turn-in-first-test-tp4717029p4717029.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: Choice always return turn in first test

Posted by garrydias <ga...@gmail.com>.
I already tried that =(

--
View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-true-in-first-test-tp4717029p4719253.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice always return turn in first test

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

Try without the quotes in the key
                        <camel:simple>${in.body.property[key]} == 'not
garrydias'</camel:simple>



On Fri, Aug 19, 2011 at 11:09 PM, garrydias <ga...@gmail.com> wrote:
> Hi folks
> it´s my scenario?:
>
> My body message is an instance of:
> *package foo;
> public class MyMessageObject
> {
>    private Map&lt;String, Serializable&gt; property;
>    // setter & gettter
>    public String toString(){ return "toString called";}
> }*
>
> My xml is:
> <bean id="wireTapMock" class="bar.RoutingSpy"/>
> <camel:camelContext id="camelContext">
>        <camel:endpoint id="endpointFileThen" uri="file://c:/dev/camel_then"
> />
>        <camel:endpoint id="endpointFileOtherwise"
> uri="file://c:/dev/camel_otherwise" />
>        <camel:route id="rout1">
>            <camel:from ref="whatever" />
>            <camel:convertBodyTo type="foo.MyMessageObject" />
>            <camel:wireTap uri="bean:wireTapMock?method=execute"/>
>            <camel:choice>
>                    <camel:when>
>                        <camel:simple>${in.body.property['key']} == 'not
> garrydias'</camel:simple>
>                        <camel:convertBodyTo type="java.lang.String" />
>                        <camel:to ref="endpointFileThen"/>
>                    </camel:when>
>                    <camel:otherwise>
>                        <camel:convertBodyTo type="java.lang.String" />
>                        <camel:to uri="endpointFileOtherwise" />
>                    </camel:otherwise>
>            </camel:choice>
>      </camel:route>
> </camel:context>
>
> wt hell my wire tap RoutingSpy.execute logs the MyMessageObject.property
> value as {key=garrydias} but the choice never goes to otherwise?
>
> I already tried:
> - invert the order in the logical test to force the cast of Serializable to
> String:
> 'not garrydias' == ${in.body.property['key']}
> - create a setHeader with ${in.body.property['key']} value an try
> <camel:simple>${in.header == 'not garrydias'</camel:simple>
> - cut off the single quotes
> <camel:simple>${in.body.property[key]} == 'not garrydias'</camel:simple>
>
> But wasn t solved
>
> I appreciate any help
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-turn-in-first-test-tp4717029p4717029.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Choice always return turn in first test

Posted by Taariq Levack <ta...@gmail.com>.
Hi

You forget to use "end"

Taariq

On 19 Aug 2011, at 11:09 PM, garrydias <ga...@gmail.com> wrote:

> Hi folks
> it´s my scenario?:
> 
> My body message is an instance of: 
> *package foo;
> public class MyMessageObject
> {
>    private Map&lt;String, Serializable&gt; property;
>    // setter & gettter
>    public String toString(){ return "toString called";}
> }*
> 
> My xml is:
> <bean id="wireTapMock" class="bar.RoutingSpy"/>
> <camel:camelContext id="camelContext">
>        <camel:endpoint id="endpointFileThen" uri="file://c:/dev/camel_then"
> />
>    <camel:endpoint id="endpointFileOtherwise"
> uri="file://c:/dev/camel_otherwise" />
>        <camel:route id="rout1">        
>            <camel:from ref="whatever" />
>            <camel:convertBodyTo type="foo.MyMessageObject" />
>            <camel:wireTap uri="bean:wireTapMock?method=execute"/>
>            <camel:choice>
>                <camel:when>
>                    <camel:simple>${in.body.property['key']} == 'not
> garrydias'</camel:simple>
>                <camel:convertBodyTo type="java.lang.String" />
>                    <camel:to ref="endpointFileThen"/>
>                </camel:when>
>            <camel:otherwise>
>                <camel:convertBodyTo type="java.lang.String" />
>                    <camel:to uri="endpointFileOtherwise" />
>            </camel:otherwise>
>        </camel:choice>
>      </camel:route>
> </camel:context>
> 
> wt hell my wire tap RoutingSpy.execute logs the MyMessageObject.property
> value as {key=garrydias} but the choice never goes to otherwise?
> 
> I already tried:
> - invert the order in the logical test to force the cast of Serializable to
> String: 
> 'not garrydias' == ${in.body.property['key']}
> - create a setHeader with ${in.body.property['key']} value an try
> <camel:simple>${in.header == 'not garrydias'</camel:simple>
> - cut off the single quotes
> <camel:simple>${in.body.property[key]} == 'not garrydias'</camel:simple>
> 
> But wasn t solved
> 
> I appreciate any help
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-turn-in-first-test-tp4717029p4717029.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice always return turn in first test [SOLVED]

Posted by garrydias <ga...@gmail.com>.
Yeah.. it works.. thank you so much..

but I tryed to access the map with [key] and did not work.. so, I think it
worked fine but I didn´t pay attention... sorry spend your time.. at least,
now I know that I can use the quotes in 2.9 ;)


thanks


--
View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-true-in-first-test-tp4717029p4723821.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice always return turn in first test

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 22, 2011 at 8:44 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Sat, Aug 20, 2011 at 11:39 PM, garrydias <ga...@gmail.com> wrote:
>> In my code, setters n getterns are ommited... I already have getProperty
>> method =/
>>
>>
>> i havn´t tried this:
>> ${in.body.property.get[key]}
>>
>> can it works??
>>
>

Hi

I just added an unit test to verify that it works in Camel
http://svn.apache.org/viewvc?rev=1160262&view=rev

Mind that I also added support for using quotes in the map access.
This is a new from Camel 2.9 onwards.
In your Camel version you cannot use the quotes, so the simple
expression should be without the quotes around the key as shown:

     .when().simple("${body.property[foo]} == 'King Kong'")




> Yeah did you try that. What version of Camel are you using?
>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-true-in-first-test-tp4717029p4719256.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Choice always return turn in first test

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Aug 20, 2011 at 11:39 PM, garrydias <ga...@gmail.com> wrote:
> In my code, setters n getterns are ommited... I already have getProperty
> method =/
>
>
> i havn´t tried this:
> ${in.body.property.get[key]}
>
> can it works??
>

Yeah did you try that. What version of Camel are you using?

>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-true-in-first-test-tp4717029p4719256.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Choice always return turn in first test

Posted by garrydias <ga...@gmail.com>.
In my code, setters n getterns are ommited... I already have getProperty
method =/


i havn´t tried this:
${in.body.property.get[key]}

can it works??



--
View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-true-in-first-test-tp4717029p4719256.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice always return turn in first test

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

You need a getter to your property. Camel must use a method to invoke it

So add a getter to it
Map getProperty() {
   return property;
}


On Fri, Aug 19, 2011 at 11:09 PM, garrydias <ga...@gmail.com> wrote:
> Hi folks
> it´s my scenario?:
>
> My body message is an instance of:
> *package foo;
> public class MyMessageObject
> {
>    private Map&lt;String, Serializable&gt; property;
>    // setter & gettter
>    public String toString(){ return "toString called";}
> }*
>
> My xml is:
> <bean id="wireTapMock" class="bar.RoutingSpy"/>
> <camel:camelContext id="camelContext">
>        <camel:endpoint id="endpointFileThen" uri="file://c:/dev/camel_then"
> />
>        <camel:endpoint id="endpointFileOtherwise"
> uri="file://c:/dev/camel_otherwise" />
>        <camel:route id="rout1">
>            <camel:from ref="whatever" />
>            <camel:convertBodyTo type="foo.MyMessageObject" />
>            <camel:wireTap uri="bean:wireTapMock?method=execute"/>
>            <camel:choice>
>                    <camel:when>
>                        <camel:simple>${in.body.property['key']} == 'not
> garrydias'</camel:simple>
>                        <camel:convertBodyTo type="java.lang.String" />
>                        <camel:to ref="endpointFileThen"/>
>                    </camel:when>
>                    <camel:otherwise>
>                        <camel:convertBodyTo type="java.lang.String" />
>                        <camel:to uri="endpointFileOtherwise" />
>                    </camel:otherwise>
>            </camel:choice>
>      </camel:route>
> </camel:context>
>
> wt hell my wire tap RoutingSpy.execute logs the MyMessageObject.property
> value as {key=garrydias} but the choice never goes to otherwise?
>
> I already tried:
> - invert the order in the logical test to force the cast of Serializable to
> String:
> 'not garrydias' == ${in.body.property['key']}
> - create a setHeader with ${in.body.property['key']} value an try
> <camel:simple>${in.header == 'not garrydias'</camel:simple>
> - cut off the single quotes
> <camel:simple>${in.body.property[key]} == 'not garrydias'</camel:simple>
>
> But wasn t solved
>
> I appreciate any help
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Choice-always-return-turn-in-first-test-tp4717029p4717029.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/