camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suralk <sura.mon...@yahoo.com>
Subject how to share variables among different exchanges
Date Thu, 04 Oct 2012 02:20:40 GMT
Hi All,
I have camel zookeeper that generates a unique node id for me, and I want to
use this id as the name of the jms queue in a different route. I tried to
use a static variable to store this id as shown below, but it is not working
(converting this static variable to an instance variable also does not
work). It (I think) is because the initialization of the static variable is
done inside the inner class Processor(). How can I achieve this
functionality? One option is to store the variable in a camel
SimpleDirectory, but then how can this directory entry be accessed inside
the from("jms:" + <get from registry>)?

public class MyRouteBuilder extends RouteBuilder {
	static String routeId="";
	@Override
    public void configure() {
 	   
 	   from("direct:start")
 	   .to(ExchangePattern.InOut,
 	      
"zookeeper://127.0.0.1:2181/routers/router?create=true&createMode=EPHEMERAL_SEQUENTIAL")
 	       .process(new Processor() {
             	public void process(Exchange exchange) throws Exception {
             	   routeId = exchange.getIn().getBody(String.class);	
             	}
             });
 	   
 	   from("jms:" + routeId) 	  
 	   .to("jason:belief");
}
}




--
View this message in context: http://camel.465427.n5.nabble.com/how-to-share-variables-among-different-exchanges-tp5720524.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message