Run EnsLib.FTP.InboundAdapter on demand
Hello community.
I have a request from a client who wants to do the following.
Currently, they have a data upload process via FTP in which they have implemented a RecordMap to store the information of the CSV files that are uploaded to the FTP directory.
Now they want to have another directory so that it is ONLY executed through an external instruction, not when the file is uploaded to the directory.
Is it possible to create a process that reads the FTP directory on demand? That is, ONLY executes the EnsLib.FTP.InboundAdapter service when we tell it to.
There would be no problem creating an API service that is responsible for receiving the execution request and invoking the Business Service to start it.
Comments
Yes, it is possible to create a process that reads an FTP directory on demand using InterSystems IRIS or Ensemble, instead of relying on automatic execution upon file upload. This can be achieved by customizing or using an API service to trigger the execution when needed. Here's how you can implement this:
Custom Schedule Control:
- By default, the
EnsLib.FTP.InboundAdapteracts as a daemon and automatically processes files whenever they are uploaded. If you want to execute file reading manually, you can implement an API or script to invoke the process directly rather than relying on its active schedule. - The FTP Inbound Adapter has methods like
OnProcessInput()that handle the input processing. You can override or modify this behavior for manual triggering via external instructions such as APIs [1][2].
- By default, the
Call the Service Manually Using an API:
Example Business Process Setup:
Example Implementation:
- Create a custom business service class extending the desired FTP adapter (
EnsLib.FTP.InboundAdapter) and configure a method that processes files only when a message is received or when a custom trigger is invoked. - For instance:
Class CustomFTPService Extends EnsLib.FTP.InboundAdapter { Parameter ADAPTER = "EnsLib.FTP.InboundAdapter"; Method TriggerFileProcessing() As %Status { // Custom logic to process FTP files Quit $$$OK } } - Additionally, the actual invocation of the adapter's file handling methods such as
NameListorGetStreamcan be customized for manual setups [1][2].
- Create a custom business service class extending the desired FTP adapter (
Usage of Management Portal:
- Add and configure the above operation or method inside your InterSystems Production using the Management Portal. It allows you to create an appropriate API or external service to control the process [2].
If you need additional detail or guidance on specific implementation steps (e.g., invoking external systems or handling the adapter operations), further exploration of the FTP adapter methods is recommended, as they support flexible configurations and manual triggers [1][2].
Sources:
You could consider using SemaphoreSpec and allow the folks placing the file in the FTP directory to also place the semaphore file in the directory on their external instruction.
Thanks for the information. I'll have a look the instructions how to implement a Semaphore.