FilePoller is used to poll for files in a specific directorypolls for files with the specified name to move it to a specified directory. It scans the specified directory, checks for an addition of new files or modification of a file and then transfers it from the source directory to the target directory.
Configuration and Testing
Business logic microservice configuration details are configured provided in this panel. The microservice supports adding multiple configurations with each configuration having the necessary details for polling.
The figure below illustrates the panel with an attribute a single configuration (Polling) added.
Figure 1: File Poller Configuration properties
...
microservice Configuration
Compute Paths relative to Directory
The path of the directory relative to which the paths of Source Directory and Destination Directory are computed. By default, this points to the FIORANO_HOME directory. If the paths specified for Source and Destination directories Directories are not absolute, their paths are calculated relative to the directory specified here.
Note |
---|
If the path specified for Source Directory and Destination Directory is absolute, the path specified for the Compute Paths relative to Directory property will not be used in the computation of the directory paths. |
...
The directory which holds the file(s) to be read polled has to be specified in the Source Directory. All the files in this directory whose names match the pattern specified for the File name property the File Name property will be processed. The files present in the sub-directories are not considered.
An absolute path or a path relative to the directory specified in the Compute Paths relative to Directory can be provided.
Note |
---|
|
Destination Directory
The path of the directory where the target file (with the data received on the input port) is created. An absolute path of the destination directory or a path relative to the directory specified provided in Compute Paths relative to Directory can be specified here.
Note |
---|
While specifying |
...
the Destination Directory, ensure that you have permissions to create/modify files present in this directory. |
File name
The name of the file to which the input data has needs to be written is specified here. If the file with this name does not exist, a new file is created.polled in the source directory. This property supports patterns such as *.csv and abc *.*, while multiple patterns are not allowed.
...
If the file with same name exists in the destination Destination folder, choose the action to be taken from the below options:
- Overwrite: Overwrites the existing file and hence the old file gets replaced with the new one.
- Rename: Renames the file with in the format - "filename + MMddyyHHmmss + counter(optional)" retaining the previously existing files.
Figure 2: Options of Actions in case file name matches
If the Rename option is selected, the following properties will be visibledisplayed:
- Append date-time format
- Append Counter
Figure 3: Append settings
Append date-time format
The format in which the date and time are to be appended to the file name.
...
Extensions of the file to be filtered
<>
Extension of the files for which the transfer of files needs to be restricted. This property accepts a comma-separated list of file extensions. Example: *.zip, *.exe, *.dat.
Info | ||
---|---|---|
| ||
If this property is set to ".exe" and the file to be moved is named as "installer.exe" in the request, FilePoller ignores that request. |
Scheduler Service Configuration
Please refer to the respective section in the Common Configurations page.
Figure 4: Scheduler Service Configuration Panel
Functional Demonstration
Scenario 1
Polling for a specified file in the Source directory and moving it to the Destination directory.
Configure the FilePoller as described in the Configuration and Testing section and use the Display microservice to check the response. In the FilePoller microservice configuration choose the option "Overwrite" for the property Action if same file exists.
Figure 5: Scenario demonstration
Sample Input
Figure 6: CPS configuration when action is set to 'Overwrite'.
Sample Output
Figure 7: Output message received
Scenario 2
Polling for a specified file in the Source directory and moving it to the Destination directory. If the Destination directory contains the same file, then the target file will be appended with date and time.
Configure the FilePoller as described in the Configuration and Testing section and use the Display microservice to check the response. In the FilePoller microservice configuration, choose the option "Rename" for the property Action if same file exists.
Sample Input
Figure 8: CPS configuration when action is set to 'Rename'.
Sample Output
Figure 9: Output message received
Useful Tips
- The microservice runs on the peer server and therefore the file paths and directories mentioned in the CPS should be valid on the machine where the peer server is running. If the microservice fails over to another peer.
- Ensure that the machine on which the secondary peer server runs have the same path available.