Spring Java File Consumer

Generate a File consumer

This generator enables the deployment of your OpenLegacy Hub project as a File Consumer service in a Java runtime environment. The result is a low-code Spring Boot project, which mirrors the contract of the generated Hub project. Each method within the Hub project is transformed into a file consumer, responsible for processing files from either a local file directory or an SFTP file location and executing the associated logic.

Once deployed and running, to incorporate the latest changes from the Hub project—such as newly added methods, removed methods, or modifications to input/output fields—simply stop and restart the service.

Supported file types:

  • XML
  • CSV
  • ByteArray
  • Swift Payment Format

Configuring Data Source

This configuration is applied at the project’s contract level and will affect all methods defined within the contract.

  • File Location:
    • Local: The file is located on the local file system of the machine where the project is deployed.
    • SFTP: Retrieve the file using Secure File Transfer Protocol (SFTP). The following parameters must be specified:
      • Host: The URL of the SFTP server.
      • Port: The port number to use for the SFTP connection.
      • Authorization Type:
        • Username & Password: Specify the credentials required to connect to the SFTP server.
        • Private Key: Provide either the username and private key or just the username if the private keys are managed by the server.
Data Source Configuration

Data Source Configuration



Configuring the Consumer

In this section, users can configure the Consumer. Start by setting up the basic parameters:

  • Base Path: The directory where files are located.
  • Filename Pattern: The pattern used to identify files within the directory.
  • Poll Interval: The interval (in milliseconds) between each consumption attempt.
  • Consume By:
    • File Name: Consume files based on their name.
    • Last Modified Date: Consume files by their last modification date.
    • Created Date: Consume files by their creation date.
  • Consume Order: The order in which files are consumed:
    • Ascending: Consume in ascending order (earliest to latest or alphabetically by file name).
    • Descending: Consume in descending order (latest to earliest or reverse alphabetical order by file name).



Configuring the Consume Strategy

In this section, users can define the strategy for handling files during the consumption process.

  • On Success: Defines the action to take after successfully consuming a file.
    • Move to Success Folder: Specify the folder path where successfully processed files will be moved.
    • Delete: Permanently remove the file after successful consumption.
  • On Failure: Defines the action to take when file consumption fails.
    • Move to Failure Folder: Specify the folder path where failed files will be moved.
    • Keep the File in Current Folder: Retain the file in its original location to retry consumption later.

Configure Consume Strategy

Configure Consume Strategy



Configuring the File Type

In this final section, users can specify the type of file the consumer will process.

  • Encoding: Defines the file encoding to be used for consumption. The default encoding is UTF-8.
  • File Type: Select the type of content to consume:
    • XML
    • CSV
    • Byte Array
    • Swift Payment Format

If CSV is selected, additional parameters must be configured:

  • CSV Delimiter: The character or string used to separate values in the CSV file.
  • Header Size: The number of lines that make up the header in the CSV file. The consumer will ignore these lines during processing.
  • Footer Size: The number of lines that make up the footer in the CSV file. The consumer will also ignore these lines.