Hi,

I am working on a Camel Route that uses the Sftp component. I have set the
maximumReconnectAttempts to 3, but whenever the connection fails I get 8
attempts - that is, twice as expected (1 attempt + 3 retries). After some
debugging I noticed that the method connect from
org.apache.camel.component.file.remote.SftpOperations is called twice. This
method is in charge of trying to connect to the FTP server and perform the
configured retries. As a result, I get 4 attempts twice. The first 4
attempts are spaced by the value configured in reconnectDelay, and
immediately after that another group of 4 attempts with the correct delay.
I tried to check if there was something wrong with my settings but did not
find anything. I believe that there might be a bug that duplicates the
number of retries the component executes. Below is a brief description of my
findings.

Methods Involved:

- org.apache.camel.component.file.remote.RemoteFileProducer.preWritheCheck
-
org.apache.camel.component.file.remote.RemoteFileProducer.recoverableConnectIfNecessary
-
org.apache.camel.component.file.remote.RemoteFileProducer.connectIfNecessary
- org.apache.camel.component.file.remote.SftpOperations.connect

Flow:

- preWritheCheck
  This method will call recoverableConnectIfNecessary if
maximumReconnectAttempts > 0, which is our case. Otherwise it will call
connectIfNecessary directly (when we set 0 retries, we don't have this
issue)
- recoverableConnectIfNecessary
  First, this method will call connectIfNecessary. If if fails, it will call
it again (this appears to be the problem)

- connectIfNecessary
  This method calls connect (if not already connected)

- connect
  This is the method that effectively tries to connect to the sFTP server
and retries the number of times desired.

The thing is that after method connect fails, recoverableConnectIfNecessary
will call method connect again (through connectIfNecessary), duplicating the
number of retries. This also explains why we get the first attempts with the
correct delay and immediately after a second group of attempts (that is, in
our case, the 5th attempt has no delay).

Please let me know if I am missing something here.

Camel Version: 2.14.0 (although I tested with 2.14.3 and 2.15.2 with the
same results)

Thanks for your help!

Ignatius



--
View this message in context: 
http://camel.465427.n5.nabble.com/SFTP-Twice-as-many-retries-as-specified-in-maximumReconnectAttempts-tp5770168.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to