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

Pollenrich issue while consuming second file with the same name



    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.10.4, 2.16.3
    • None
    • came-core, camel-sftp
    • None
    • Unknown


      Pollenrich issue while consuming second file with the same name

      We have implemented a logic where a checksum will be compared during poll enrich using aggregationStrategy.

      Below is the entire flow of this logic

      1. Poll xls file from sftp location. Lets say the name of the file will be sample.xls

      2. Poll subsequent sha file where the name will be sample.xls.sha512
      3. Polling sha file using pollenrich is as below

      from("direct:" + routeId)
      .process(new ShutDownProcessor())
      "Polling SHA512 checksum for transfered file '${in.header.CamelFileName}' with timeout " + timeout + " ms")
      .log(LoggingLevel.DEBUG,"SHA512 dynamic polling route details: enrichUri: " + this.enrichUri)
      .convertBodyTo(byte[].class, "UTF-8")
      .pollEnrich(enrichUri, timeout, MY_AGGREGATION_STRATEGY)
      enrichUri - "source.ftp.endpointftp.sha512.poll.options" + "&fileName=" + fileName + ".sha512"
      timeout - 30000
      MY_AGGREGATION_STRATEGY - Strategy to compare old checksum

      4. Aggregator logic has been implemeted as below.

      public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
      if (newExchange == null)

      { log.error("No sftp file found for the input file!"); throw new RuntimeException("No sftp file found for the input file!"); }

      Message sha512Msg = newExchange.hasOut() ? newExchange.getOut() : newExchange.getIn();
      Message incomingMsg = oldExchange.hasOut() ? oldExchange.getOut() : oldExchange.getIn();

      try {
      String incomingSHA512 = fetch sha of received file
      String computedSHA512 = fetch sha of computed file


      { log.info("SHA512 check for file '" + oldExchange.getIn().getHeader("CamelFileName", String.class) + "' successful."); return oldExchange; }


      { throw new RuntimeException("Computed SHA512 checksum '" + computedSHA512 + "' does not match with provided SHA512 checksum '" + incomingSHA512 + "'"); }

      } catch (Exception e)

      { log.error("Error while processing SHA512 checksum of the passing file: " + e.getMessage()); throw new RuntimeException(e); }

      Now the issue which we are facing is

      1. First time if we introduce sample.xls and corresponding sha file where checksum doesnt match, then it will throw an exception and the file will be moved to failed folder. This is an expected behavior and works fine.
      2. If we introduce the same file again with the same name, then sample.xls file will be consumed, but corresponding sha file will not be consumed. The file is present in the location but still it will landeup in "No sftp file found for the input file!" which we have logged in aggregate method.
      3. Those file will consume if i restart the server.

      We have tried below
      1. We are using camel 2.10.4 and tried with 2.16.3.
      2. Adding idempotent=false in ftp.sha512.poll.options.
      3. Changing timer and keep it for quite a long time.

      But still facing same issue.

      Are we missing anything here?




            Unassigned Unassigned
            sharathchitra Sharath
            0 Vote for this issue
            2 Start watching this issue