file nio ingress connector

NIO File Ingress Connector

Version: 17.01

Supported Since: 17.01

What is NIO File Ingress Connector?

NIO file transport acts as a non-polling transport which will trigger an event if and only if there is a file or a directory is created or modified. In a polling transport, it scans for a directory or set of directories by a given time period of interval. That will be an overhead and insufficient use of system resources since it scans for set or directories and files periodically even though there are no files in those.

How this Works?

The JDK 7 provided a special package called java.nio. Java NIO (New IO) is an alternative IO API for Java (from Java 1.4), meaning alternative to the standard Java IO and Java Networking API’s. Java NIO offers a different way of working with IO than the standard IO API’s. This package provided a package called java.nio.file and it has a file change notification API, called the WatchService API. This API enables to register a directory (or directories) with the watch service. When the service get started it detects all the events of creation or modification of files and directories.

Sample Use Case

Prerequisite

In order to use the NIO File Ingress Connector you must first select the “NIO File Connector” dependency from the connector list when you are creating an empty Ultra project. If you have already created a project, you can add the “NIO File Connector” dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list, select the “NIO File Connector” dependency.

Implementation

First let’s create our integration flow named “SampleFlow” and add a NIO File Ingress Connector to that, and as for the root path specify the file path which you are going to scan the files for. Then select the pattern syntax which is glob or regex and specify the file path pattern according to the pattern syntax and save the configuration.

nio file ingress connector 1
The set of file paths which should be scanned for the files are generated using the above specified root path and file path pattern. See the example below.

Root Path

Pattern Syntax

Path Pattern

Description

/tmp

glob

*.xml

all the xml files inside the tmp directory

/tmp

glob

/*/.xml

all the xml files inside any level of directories in tmp directory

/tmp

glob

/a/.xml

all the xml files inside the directories which names ends with a in the tmp directory

/tmp

regex

\d.xml

all the xml files which name is a single digit from 0-9 in the tmp directory

Next include a Successful Flow End element and connect it to the NIO File Ingress Connector to complete the flow as shown below.

nio file ingress connector 2

Now after running the project, you will be able to see that all the files which match the path pattern have been successfully picked up from the any directory which matches the root directory and the path pattern you specified.

Out Ports

Processor

The message will be sent to this outport for the next processing element

On Exception

The message will be sent to this outport if the processing element failed to transform the payload due to some reason

Parameters

* marked fields are mandatory

Root path *

Basic

This is the base path of the file system which you going to scan the files for. You can specify any file path pattern later at the 'Path pattern' field and that will be checked beyond this root path.

Pattern syntax *

Basic

There are 2 types of pattern syntax which we can match with the file paths of the local file system. This will be related to the 'Path pattern' field which you going to fill next.

GLOB
REGEX

Path pattern *

Basic

File path pattern which we need to scan for the files. This can be just a file pattern or file pattern with the directory pattern.

The path pattern should match with the pattern syntax mentioned above

Remove original file

Advanced

This says whether to delete the original file after it is fetched by the transport.

Wait after modification

Advanced

This says not to fetch files until this amount of time (IN MILLISECONDS) has passed since the last modified file timestamp.

Move after process

Advanced

Directory path to move the file after processing and if it is success.

If the move after process directory matches the path pattern mentioned above this file will be fetched again by the watch service. Then this will be happen circularly without stopping.

Move after failure

Advanced

Directory path to move the file after processing and if it is failed.

If the move after failure directory matches the path pattern mentioned above this file will be fetched again by the watch service. Then this will be happen circularly without stopping.

Move timestamp format

Advanced

This timestamp format is to be appended while moving original file after processing. File name of the file which is going to be moved will be renamed by appending this timestamp format at the beginning of file name.

yyyy-MM-dd HH:mm:ss.S AM/PM Z

In this topic
In this topic
Contact Us