camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ravi.4indra" <ravi.4in...@gmail.com>
Subject Re: Camel Timeout on a route
Date Fri, 26 Oct 2012 19:43:29 GMT
Hi Raul,

can you please provide your inputs on the below piece of code. 

This method the uses the producer template asyncCallback to call the
commonRoute.and i used the future handle to get the response.

  public void getDataUsingProducerTemplate(Exchange exchange) throws
TimeoutException, InterruptedException, ExecutionException {
    	ProducerTemplate template = camelContext.createProducerTemplate();
    	Future<Exchange> future = template.asyncCallback("direct:commonRoute",
exchange, new  SynchronizationImpl());
    	// Retrieve the reply from the main thread, specifying a timeout
    	try {
			future.get(2, TimeUnit.SECONDS);
		}catch (TimeoutException e) {
			//exchange.setException(e);
			future.cancel(true);
Thread.sleep(1000)
			throw e;			
		}
}

Without the thread sleep my global exception handler (On Exception) is not
able to catch the exception.

Thanks
Ravi




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Timeout-on-a-route-tp5721576p5721623.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message