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.

9 comments:

  1. hi Kevin,very good explanation..keep blogging more about wM..

    ReplyDelete
  2. thanks for blogging this, very helpful :)

    ReplyDelete
  3. Some tips:
    The package would generally be set to the one your application lives in.. That way when you migrate it up to higher environments (e.g. via WmDeployer or CrossVista TEAM) you will have it appear there..

    Also: you don't need to do file operations on the file name to retrieve it if it can work out what the content type is. e.g. if it is an xml file then it will be as an xml node if it is "application/x–wmflatfile" then you'll get the ffdata (flat file stuff).
    To test this stuff you can do a pub.flow:tracePipeline which will show you all the stuff fed into the handler service.

    ReplyDelete
  4. I have one question. Does the processing service moves the file from input to working folders?

    ReplyDelete
    Replies
    1. The Fill Polling system itself moves the file from the input folder to the working folder before calling your service and then either to the done folder or the error folder depending on the exit condition of the service you wrote. You don't need to do any file movements.

      Delete
  5. Hi Kevin,

    Very nice to see your blog, you can now create useful blogs at http://idnxchange.com/webmethods-blogs.html which got more than 1400 Registered wM users. You can also create your business card to show your skills and expertise, checkout a sample http://idnxchange.com/component/idn/?view=businesscard&id=137 .

    Hope to see you soon at IDN.

    Thanks and Regards,
    Team IDN

    ReplyDelete
  6. Thank you Kevin.

    Solved all the questions i had.

    ReplyDelete
  7. Has anyone tried creating the clean up service? What are the inputs required for that?

    ReplyDelete
  8. Is file polling works without working directory?

    ReplyDelete