Question
· Oct 21

How to process EnsLib.RecordMap.Service.FTPService files one by one?

Hi community,

I have a service that uses EnsLib.RecordMap.Service.FTPService to capture files in an FTP directory.

Instead of uploading them all at once, I would need to do so one at a time.

I have a class that extends this class because it preprocesses, saves everything in the RecordMap class, and then processes all the records at once.

When I invoke the BP, it does so through the method set tStatus = ..SendRequest(message, 1).

I've set the SynchronousSend flag to 1, but it continues processing all the files at once.

Is there a way to prevent the process from continuing to the next file until the BP indicates it's finished?

Best regards.

Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1.3 (Build 389U) Wed Feb 15 2023 14:50:06 EST
Discussion (1)2
Log in or sign up to continue

To process files captured using EnsLib.RecordMap.Service.FTPService one by one, you can use the following approach:

The EnsLib.RecordMap.Service.FTPService class monitors a defined FTP directory and automatically processes files as they arrive. Ensuring one file processes completely before the next requires modifying how the service interacts with the Business Process.

  1. Synchronous Processing: Set the SynchronousSend flag to 1 to ensure messages are sent and processed one at a time synchronously. However, from your description, this may not currently behave as expected [1].

  2. Semaphore Spec Implementation: A potential option is to implement a semaphore mechanism. This involves placing a semaphore file in the FTP directory for every file uploaded. This configuration ensures the Business Service checks for the semaphore file before processing each new file, effectively creating a queue-like mechanism. Details for implementing semaphore can be found here: [2].

  3. Custom Service Extension: Extend the EnsLib.RecordMap.Service.FTPService class and modify its behavior. In the OnProcessInput method, you might introduce a custom logic to ensure the processing waits until you confirm that the previous file has been completely processed, possibly by interacting with the Business Process regarding completion before proceeding to the next file [3].

  4. On-Demand Execution: Another solution is setting up an API to trigger the processing of the FTP directory. Instead of automatically processing files upon upload, the directory can be read manually or triggered via an API request. This way, you can ensure the files are processed one by one [2].

For detailed guidance and support, consider exploring semaphore as outlined or consult the Developer Community for further clarification.

Sources: