Tuesday, August 23, 2011

File Polling Setup and Usage.

Checking for a file that is placed on your IS or on a shared directory?  The documentation is lacking and incomplete.  Here's how to set it up.

File Polling Port Setup

In IS Admin, look under security->ports.  Click "Add Port" and select webMethods/FilePolling.  Now you are at the File Polling listener configuration screen.

Leave the package name as WmRoot.
The monitoring directory is the location you want to look for files.
The working, completion and error directories are all optional (sort of).  If you do not specify them, then they will default to the <monitoring directory>/../<type>.  I prefer to specify them explicitly.

Processing Service is the name of the service that will be called when a new file is placed in the monitoring directory (and the polling schedule hits).

File Polling Interval is how often the poller checks for a file.  Times of 1 second are not recommended.

I cannot comment too much on the other settings as I'm not using them.

Once that is done, you need to save changes, then enable the port.  If you don't have write permissions to the directories in the config (or the implicit directories if you didn't specify the optional directories) then you will get an error.

Service Setup

Create a flow service with one input:
originalFileName

This is put on the pipeline when the service is called, though not necessary as it also comes in the next step.

You then want to call pub.flow.getTransportInfo from WmPublic.  This will provide the filename information in:
transport->filePolling
    filename
    originalFilename

At this point the filename will in the format of:
<workingdir>/FilePolling.<ID Num>.<original file name>

Now you can do any file operations you'd normally do on a file and process it however you want.

If your flow service exits and signals failure, the file will be moved to the error directory.

If your flow service exits correctly, the file will be moved to the completion directory.


Access Mode Setup


Once you have your port setup and configured  and your service created, you need to enable access from the file poller.  Go back to the IS Admin screen in Security->Ports and edit the Access Mode of your file poller.


Click to "Add Folders and Services to Allow List" and paste in the fully qualified flow service into the left column and click "Save Additions".


Without this step you will get access denied errors when your file poller tries to run.



It's not hard, but it sure wasn't straightforward the first time I looked at it.