SFTP File Mediation

Version: 17.01

Supported Since: 17.01

Use case description

I want to mediate large JSON files via SFTP from one system to another after modifying the file name based on the value received as field in the input file. File name should be modified by attaching the received client ID as the prefix of the original file name by using the underscore as the separator. Client ID will be available at the pre-defined JSON path of the received input file content.

Proposed Solution

As the solution for this, we have decided to mediate files thorough an ESB as shown in the below diagram.

sftp file mediation

ESB will fetch file from the source SFTP server and extract the client ID by evaluating a pre-configured JSON path over the received file content. This client ID will append as the prefix to the original file name. So the final file name would be like <received_client_id>_<original_file_name>. With this file name modification, received file will be uploaded to the target SFTP server using the SFTP sender.

Implementation of the Solution

Prerequisite

In order to implement above use case, first we should add the SFTP Connector from the connector list and Content Extractor, Logger from the processors list when we are creating an empty Ultra project.

Same can be done to an existing project via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors and Processors list, select above dependencies
Implementation

To implement above use case, first let’s create our integration flow named “sftp-file-mediating”. Then let’s add required components by going through following steps in order.

  1. Add an SFTP Ingress Connector from the connectors list, to fetch the files from the source SFTP server. SFTP Ingress Connector basic parameter should be filled as below table to fetch the JSON files from the source system.

  2. Add a JSON path extractor processing element to extract out the client ID from the input message content. As per the following structure of the message JSON path for the client ID will be "$.Client-ID". Let’s save the extracted client ID value as the variable with name "CLIENT_ID" by configuring the "Variable Name" parameter of the processing element.

{
  "First name": "Brian",
    "Last name": "Novik",
    "Client-ID" : "DC0-453291",
    "Organization": {
      "id": "100123H",
      "name" : "ABC Company"
    },
    "Orders": [
      ....
      orders
      ....
    ]
  ....
  rest of the content of the input JSON message
  ....
}
  1. Let’s add a Logger processing element to log the received file name to make sure that we have information about the processed files from the SFTP Ingress Connector. Let’s configure "Log Template" as "Received file with name : @{message.header.ultra.file.name} for client ID : @{message.var.CLIENT_ID}" to log both received file name and extracted client ID value.

  2. As the last element, let’s add an SFTP EgressConnector element to the integration flow to send the file to the target SFTP server as per the requirement use case. SFTP EgressConnector can be configured by filling the Basic properties as shown in the following table. To modify the file name as described in the use case, "File Name" property should be configured as "@{message.var.CLIENT_ID}_@{message.header.ultra.file.name}" which contains the value of the variable with name CLIENT_ID and the original file name of the received input file.

sftp file mediation 1

Each element of the flow should be filled as below

1

SFTP Ingress Connector

sftp file mediation 2

If you are using key based authentication for SFTP connectivity, then you have to configure the key based authentication related configurations in the Key Authentication tab

2

JSON Path Extractor

sftp file mediation 3

3

Logger Processing Element

sftp file mediation 4

4

SFTP Egress Connector

sftp file mediation 5

Now you can run the integration flow and check the SFTP file mediating working as expected. If you put a input file with .json file name extension to the configured SFTP source location, your integration flow should fetch the file and upload it to the target SFTP server with the required file name modification.

Property Configuration

When running the sample in the UltraESB-X distribution, you need to override the following properties in-order for the sample to work.

Refer to Managing Project Properties documentation on how to override properties.

SFTPEgressConnector.sftp-ingress-connector.host

Hostname/ IP of the source SFTP sever

SFTPIngressConnector.sftp-ingress-connector.port

Port of the source SFTP sever

SFTPIngressConnector.sftp-ingress-connector.username

Username for the source SFTP sever

SFTPIngressConnector.sftp-ingress-connector.password

Password for the source SFTP sever

SFTPIngressConnector.sftp-ingress-connector.fetchPath

File path fetch files from the source SFTP sever

SFTPEgressConnector.sftp-egress-connector.host

Hostname/ IP of the destination SFTP sever

SFTPEgressConnector.sftp-egress-connector.port

Port of the destination SFTP sever

SFTPEgressConnector.sftp-egress-connector.username

Username for the destination SFTP sever

SFTPEgressConnector.sftp-egress-connector.password

Password for the destination SFTP sever

SFTPEgressConnector.sftp-egress-connector.filePath

Path to upload file in the destination SFTP sever

In this topic
In this topic
Contact Us