-
1. Re: Exception handling
davsclaus Aug 23, 2009 8:48 AM (in response to sriram_imshriram)Hi
Thanks for the words about the forums.
In Camel 2.0 we have added doTry .. doCatch .. doFinally so you could do something that you can easily do in regular java.
However in Camel 1.x and/or 2.0 sometimes its easier to just use a processor where you can invoke your server in a try .. catch and handle the exception there.
So replace .to(server) with .process(new MyCallServerProcessor())
And in this processor you can invoke the server and handle the response
public void process(Exchange exchange) { ProducerTemplate template = exchange.getContext().createNewProducerTemplate(); template.send("server uri", exchange); Exception e = exchange.getException(); if (e != null) { // we got an exception when calling the server } }
-
2. Re: Exception handling
davsclaus Aug 23, 2009 8:49 AM (in response to davsclaus)About the try .. catch stuff
http://davsclaus.blogspot.com/2009/04/on-road-to-camel-20-try-catch-finally.html
-
3. Re: Exception handling
sriram_imshriram Aug 28, 2009 5:53 AM (in response to sriram_imshriram)Thank you very much......you guys are real good......
-
4. Re: Exception handling
parasmk Oct 6, 2009 6:04 AM (in response to sriram_imshriram)I have a similar problem, except my server is the producer as opposed to client in Sriram's case.
I need to transfer files from a FTP server to a local directory and know if the server is down and if so retry every 10 minutes. Is there any method to catch exceptions from the producer?
Camel doTry/doCatch, I believe, catches exceptions within the exchange, i.e. after the from(). producer.
My route: from("ftp:// ...").to("file:// ..."). I'm using camel-2.0-M3.
Thanks a lot in advance. By the way, thanks for your contribution to this cause.
Regards,
Paras
<!
Session data> -
5. Re: Exception handling
davsclaus Oct 7, 2009 1:40 PM (in response to parasmk)Are you sure you mean producer? You want to consume messages from a remote FTP server? So I assume its consumer you mean.
Camel will by default retry so you do not really need to do anything than define the delay. So if you want 10 min delay then set it as delay=600000 as its value is in milli seconds.
from("ftp://someone@somewhere:21/foo?consumer.delay=600000")
In Camel 2.0 you can fine tune what to do in case the remote ftp server has a problem. Its the option.