You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by clipod <ni...@gmail.com> on 2013/07/11 23:46:05 UTC

Accessing a local declared hashmap variable in a route

Hi, 
I have a camel route with a choice block. I want to use a hashmap inside a
when condition. 
To be more precise I would like to know if there is a way to use the
"containsKey" function inside when.
Is there a way to handle this. I can actually create a processor and define
the behaviour but I would like to do it in the route itself.



--
View this message in context: http://camel.465427.n5.nabble.com/Accessing-a-local-declared-hashmap-variable-in-a-route-tp5735553.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Accessing a local declared hashmap variable in a route

Posted by clipod <ni...@gmail.com>.
I think I found the answer. This is what I did

public class CancelSubscriptionRoute extends SpringRouteBuilder {

	public static Map<String, BillingAPIException> brmResults = new
HashMap<String, BillingAPIException>();

public void configure() throws Exception {		

		from(GET_CANCEL_BY_ACCOUNT).id("cancelSubscription")
			.setHeader("statusMap", constant(brmResults))
...........
...........
...........
}

Using constant to load a hashmap into a header.



--
View this message in context: http://camel.465427.n5.nabble.com/Accessing-a-local-declared-hashmap-variable-in-a-route-tp5735553p5735681.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Accessing a local declared hashmap variable in a route

Posted by boday <be...@initekconsulting.com>.
you can use camel-simple to do this...

from("direct:start")
      .choice()
             .when().simple("${body.keySet} contains 'foo'")
                    .to("mock:king")
             .otherwise()
                    .to("mock:other");


clipod wrote
> Hi, 
> I have a camel route with a choice block. I want to use a hashmap inside a
> when condition. 
> To be more precise I would like to know if there is a way to use the
> "containsKey" function inside when.
> Is there a way to handle this. I can actually create a processor and
> define the behaviour but I would like to do it in the route itself.





-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/Accessing-a-local-declared-hashmap-variable-in-a-route-tp5735553p5735646.html
Sent from the Camel - Users mailing list archive at Nabble.com.