Consumer Polling Retry Issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Consumer Polling Retry Issue

yeandone
Hi, Camel friends.

  I am trying to poll files from a remote SFTP server. I am currently setting consumer.bridgeErrorHandler=true at the from URI. When it cannot connect the server, exception is thrown and caught by error handler. If I do not set consumer.bridgeErrorHandler=true, then when an error is thrown, the consumer will never stop polling as the exception is never handled.  So if not able to connect to remote server, I want to implement below logic:

First retry 5 times,  if the connection is not still successful after retrying 5 times, I want exception to be caught and handled.


Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Consumer Polling Retry Issue

yeandone
Hi Claus and Willem

  Do you happen to have any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Consumer Polling Retry Issue

Claus Ibsen-2
In reply to this post by yeandone
Hi

At the documentation
http://camel.apache.org/ftp2

There is a maximumReconnectAttempts option

On Tue, Mar 24, 2015 at 7:18 PM, lye <[hidden email]> wrote:

> Hi, Camel friends.
>
>   I am trying to poll files from a remote SFTP server. I am currently
> setting consumer.bridgeErrorHandler=true at the from URI. When it cannot
> connect the server, exception is thrown and caught by error handler. If I do
> not set consumer.bridgeErrorHandler=true, then when an error is thrown, the
> consumer will never stop polling as the exception is never handled.  So if
> not able to connect to remote server, I want to implement below logic:
>
> First retry 5 times,  if the connection is not still successful after
> retrying 5 times, I want exception to be caught and handled.
>
>
> Thanks!
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consumer-Polling-Retry-Issue-tp5764708.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
Reply | Threaded
Open this post in threaded view
|

Re: Consumer Polling Retry Issue

yeandone
Hi Claus.


  Thank you so much for your reply! I read of the doc before, but how do I catch the exception and handle it after 5 retries? Currently in my route I set consumer.bridgeErrorHandler=true. So when an exception is thrown at the first try, it will go to my "on exception" block inside the route and the error handling logic will be executed. So retries can never be executed.



Route:
                <route id="connect_route" autoStartup="false">

                <from uri="{{sftpLocation}}?privateKeyFile={{location}}&amp;sendEmptyMessageWhenIdle=true&amp;idempotent=false&amp;consumer.bridgeErrorHandler=true&amp;disconnect=false&amp;maximumReconnectAttempts=2&amp;filter=#customFileFilter"/>
                ...........
                   <onException>
                        <exception>java.lang.Exception</exception>
                        <to uri="controlbus:route?routeId=connect_route&amp;action=stop" />
                   </onException>

                </route>

                   


Reply | Threaded
Open this post in threaded view
|

Re: Consumer Polling Retry Issue

Claus Ibsen-2
Take a look at
org.apache.camel.impl.LimitedPollingConsumerPollStrategy

On Wed, Mar 25, 2015 at 6:07 PM, yeandone <[hidden email]> wrote:

> Hi Claus.
>
>
>   Thank you so much for your reply! I read of the doc before, but how do I
> catch the exception and handle it after 5 retries? Currently in my route I
> set consumer.bridgeErrorHandler=true. So when an exception is thrown at the
> first try, it will go to my "on exception" block inside the route and the
> error handling logic will be executed. So retries can never be executed.
>
>
>
> Route:
>                 <route id="connect_route" autoStartup="false">
>
>                 <from
> uri="{{sftpLocation}}?privateKeyFile={{location}}&amp;sendEmptyMessageWhenIdle=true&amp;idempotent=false&amp;consumer.bridgeErrorHandler=true&amp;disconnect=false&amp;maximumReconnectAttempts=2&amp;filter=#customFileFilter"/>
>                 ...........
>                    <onException>
>                         <exception>java.lang.Exception</exception>
>                         <to uri="controlbus:route?routeId=connect_route&amp;action=stop"
> />
>                    </onException>
>
>                 </route>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consumer-Polling-Retry-Issue-tp5764711p5764779.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [hidden email]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/