Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9512

camel-ftp - Recover from lost connection issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.14.1
    • None
    • camel-sftp
    • None
    • Unknown

    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; }

      }

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            oattari omar attari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: