You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "omar attari (JIRA)" <ji...@apache.org> on 2016/01/13 17:08:40 UTC

[jira] [Updated] (CAMEL-9512) camel-ftp - Recover from lost connection issue

     [ https://issues.apache.org/jira/browse/CAMEL-9512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

omar attari updated CAMEL-9512:
-------------------------------
    Description: 
Dears,
we are using the sftp camel route service but for unknown reasons ths sftp camel service was stop polling any file from sftp server then we need to restart the service again to polling the files again.

This condition occurs daily we need your assistent to solve it.

public class SftpRoutesBuilder
  extends RouteBuilder
{
  private static final Logger LOGGER = LoggerFactory.getLogger(SftpRoutesBuilder.class);
  private String protocol;
  private String username;
  private String password;
  private String requestUri;
  private String inProcessUri;
  private boolean passiveMode;
  private boolean binary;
  private String routeId;
  private String fileOwnerBicCode;
  private String filePurpose;
  private String privateKey;
  private String privateKeyPassphrase;
  
  public void configure()
    throws Exception
  {
    LOGGER.info("configuring the ftp routes builder");
    
    errorHandler(loggingErrorHandler(LOGGER).level(LoggingLevel.INFO));
    if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey == null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase != null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase != null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    }
  }
  
  public SftpRoutesBuilder(String protocol, String username, String password, String requestUri, String inProcessUri, boolean passiveMode, boolean binary, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
  {
    this.protocol = protocol.toLowerCase();
    this.username = username;
    this.password = password;
    this.requestUri = requestUri;
    this.inProcessUri = inProcessUri;
    this.passiveMode = passiveMode;
    this.binary = binary;
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = privateKey;
    this.privateKeyPassphrase = passPhrase;
  }
  
  public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
  {
    this.protocol = transferMethod.toLowerCase();
    this.username = username2;
    this.password = password2;
    this.requestUri = requestUri2;
    this.inProcessUri = inProccessUri;
    this.passiveMode = Boolean.TRUE.booleanValue();
    this.binary = Boolean.TRUE.booleanValue();
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = privateKey;
    this.privateKeyPassphrase = passPhrase;
  }
  
  public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose)
  {
    this.protocol = transferMethod.toLowerCase();
    this.username = username2;
    this.password = password2;
    this.requestUri = requestUri2;
    this.inProcessUri = inProccessUri;
    this.passiveMode = Boolean.TRUE.booleanValue();
    this.binary = Boolean.TRUE.booleanValue();
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = null;
  }
}



  was:
Dears,
we are using the sftp camel route but in daily bases for unknown reasons ths sftp camel servise was stop polling any file from sftp server but when close the service and reopen it the problem not happend again in this day and this is my code :
package com.progressoft.jfw.model.opay.ftp.camel;

import com.progressoft.jfw.model.opay.comm.properties.PropertiesLoader;
import java.text.MessageFormat;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.ExpressionClause;
import org.apache.camel.builder.LoggingErrorHandlerBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.model.RouteDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SftpRoutesBuilder
  extends RouteBuilder
{
  private static final Logger LOGGER = LoggerFactory.getLogger(SftpRoutesBuilder.class);
  private String protocol;
  private String username;
  private String password;
  private String requestUri;
  private String inProcessUri;
  private boolean passiveMode;
  private boolean binary;
  private String routeId;
  private String fileOwnerBicCode;
  private String filePurpose;
  private String privateKey;
  private String privateKeyPassphrase;
  
  public void configure()
    throws Exception
  {
    LOGGER.info("configuring the ftp routes builder");
    
    errorHandler(loggingErrorHandler(LOGGER).level(LoggingLevel.INFO));
    if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey == null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase != null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    } else if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase != null)) {
      ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
    }
  }
  
  public SftpRoutesBuilder(String protocol, String username, String password, String requestUri, String inProcessUri, boolean passiveMode, boolean binary, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
  {
    this.protocol = protocol.toLowerCase();
    this.username = username;
    this.password = password;
    this.requestUri = requestUri;
    this.inProcessUri = inProcessUri;
    this.passiveMode = passiveMode;
    this.binary = binary;
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = privateKey;
    this.privateKeyPassphrase = passPhrase;
  }
  
  public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
  {
    this.protocol = transferMethod.toLowerCase();
    this.username = username2;
    this.password = password2;
    this.requestUri = requestUri2;
    this.inProcessUri = inProccessUri;
    this.passiveMode = Boolean.TRUE.booleanValue();
    this.binary = Boolean.TRUE.booleanValue();
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = privateKey;
    this.privateKeyPassphrase = passPhrase;
  }
  
  public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose)
  {
    this.protocol = transferMethod.toLowerCase();
    this.username = username2;
    this.password = password2;
    this.requestUri = requestUri2;
    this.inProcessUri = inProccessUri;
    this.passiveMode = Boolean.TRUE.booleanValue();
    this.binary = Boolean.TRUE.booleanValue();
    this.routeId = routeId;
    this.fileOwnerBicCode = fileOwnerBicCode;
    this.filePurpose = filePurpose;
    this.privateKey = null;
  }
}

from sftp file builder class


> camel-ftp - Recover from lost connection issue
> ----------------------------------------------
>
>                 Key: CAMEL-9512
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9512
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-sftp
>    Affects Versions: 2.14.1
>            Reporter: omar attari
>
> Dears,
> we are using the sftp camel route service but for unknown reasons ths sftp camel service was stop polling any file from sftp server then we need to restart the service again to polling the files again.
> This condition occurs daily we need your assistent to solve it.
> public class SftpRoutesBuilder
>   extends RouteBuilder
> {
>   private static final Logger LOGGER = LoggerFactory.getLogger(SftpRoutesBuilder.class);
>   private String protocol;
>   private String username;
>   private String password;
>   private String requestUri;
>   private String inProcessUri;
>   private boolean passiveMode;
>   private boolean binary;
>   private String routeId;
>   private String fileOwnerBicCode;
>   private String filePurpose;
>   private String privateKey;
>   private String privateKeyPassphrase;
>   
>   public void configure()
>     throws Exception
>   {
>     LOGGER.info("configuring the ftp routes builder");
>     
>     errorHandler(loggingErrorHandler(LOGGER).level(LoggingLevel.INFO));
>     if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
>       ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
>     } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase == null)) {
>       ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
>     } else if ((this.privateKey == null) && (this.password != null) && (this.privateKeyPassphrase == null)) {
>       ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}", new Object[] { this.protocol, this.username, this.password, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary) }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
>     } else if ((this.privateKey != null) && (this.password == null) && (this.privateKeyPassphrase != null)) {
>       ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.requestUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?passiveMode={3}&binary={4}&privateKey={5}&privateKeyPassphrase={6}", new Object[] { this.protocol, this.username, this.inProcessUri, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
>     } else if ((this.privateKey != null) && (this.password != null) && (this.privateKeyPassphrase != null)) {
>       ((RouteDefinition)((RouteDefinition)((RouteDefinition)((ProcessorDefinition)((ProcessorDefinition)((ProcessorDefinition)from(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.requestUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&delay=60000&delete=true&" + "maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route")).setProperty("fileName").simple("CamelFileName")).setProperty("fileOwnerBicCode").simple(this.fileOwnerBicCode)).setProperty("filePurpose").simple(this.filePurpose)).to(MessageFormat.format("{0}://{1}@{2}?password={3}&passiveMode={4}&binary={5}&privateKey={6}&privateKeyPassphrase={7}", new Object[] { this.protocol, this.username, this.inProcessUri, this.password, Boolean.valueOf(this.passiveMode), Boolean.valueOf(this.binary), this.privateKey, this.privateKeyPassphrase }) + "&maximumReconnectAttempts=" + PropertiesLoader.getInstance().getPropertyValue("ftp.maximum.reconnect.attempts") + "&reconnectDelay=" + PropertiesLoader.getInstance().getPropertyValue("ftp.reconnect.delay") + "&disconnect=" + PropertiesLoader.getInstance().getPropertyValue("disconnect.route"))).convertBodyTo(byte[].class)).process(new FtpFilesProcessor())).routeId(this.routeId);
>     }
>   }
>   
>   public SftpRoutesBuilder(String protocol, String username, String password, String requestUri, String inProcessUri, boolean passiveMode, boolean binary, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
>   {
>     this.protocol = protocol.toLowerCase();
>     this.username = username;
>     this.password = password;
>     this.requestUri = requestUri;
>     this.inProcessUri = inProcessUri;
>     this.passiveMode = passiveMode;
>     this.binary = binary;
>     this.routeId = routeId;
>     this.fileOwnerBicCode = fileOwnerBicCode;
>     this.filePurpose = filePurpose;
>     this.privateKey = privateKey;
>     this.privateKeyPassphrase = passPhrase;
>   }
>   
>   public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose, String privateKey, String passPhrase)
>   {
>     this.protocol = transferMethod.toLowerCase();
>     this.username = username2;
>     this.password = password2;
>     this.requestUri = requestUri2;
>     this.inProcessUri = inProccessUri;
>     this.passiveMode = Boolean.TRUE.booleanValue();
>     this.binary = Boolean.TRUE.booleanValue();
>     this.routeId = routeId;
>     this.fileOwnerBicCode = fileOwnerBicCode;
>     this.filePurpose = filePurpose;
>     this.privateKey = privateKey;
>     this.privateKeyPassphrase = passPhrase;
>   }
>   
>   public SftpRoutesBuilder(String transferMethod, String username2, String password2, String requestUri2, String inProccessUri, String routeId, String fileOwnerBicCode, String filePurpose)
>   {
>     this.protocol = transferMethod.toLowerCase();
>     this.username = username2;
>     this.password = password2;
>     this.requestUri = requestUri2;
>     this.inProcessUri = inProccessUri;
>     this.passiveMode = Boolean.TRUE.booleanValue();
>     this.binary = Boolean.TRUE.booleanValue();
>     this.routeId = routeId;
>     this.fileOwnerBicCode = fileOwnerBicCode;
>     this.filePurpose = filePurpose;
>     this.privateKey = null;
>   }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)