Skip to main content

I have a directory watch which triggers a workspace. This Workspace should be executed only once. But unfortunately with every detected file/folder a job starts. Is it possible to avoid this behavior?

 

I use FME Server 2020.1

 

Thank you for your help!

 

Sorry in advance if this topic has been discussed here before! I've couldn't find anything.

Hi @resch​ ,

 

The watcher triggers are designed to send one message to the Automation per create/modify/delete event, this means the workspace will run per event and there is no way to merge these.

 

If you would like a workspace to only run once but to process multiple file changes I think the best approach would be to use a schedule trigger set to run at a regular interval (probably the same as your polling interval in the directory watch). Then in your workspace you'd need to build in some logic to fetch only the files that have changed in this interval.

 

One way I can think of doing this is by using the Directory and File Path Names Reader to get a list of all files in the Directory and set the Retrieve File Properties parameter to yes. Using a Tester you can then check if the path_created_date or path_modified_date attribute is within the last schedule interval - this can be calculated using date time functions.

 

For example if you're schedule is run every 10 minutes you could use @DateTimeAdd(@DateTimeNow(),-PT10M) to fetch the time 10 minutes before the time the workspace is running.

 

Screen Shot 2020-10-28 at 9.43.19 AM


No, it's not. The way I handle this is to do a check in the triggered workspace and terminate if it shouldn't be run.


thank you very much for your response and advices!

 


I spoke with a Safe tech support specialist about this very thing. They insisted that it was the intended behavior, but I struggle to understand how it's reasonable to assume that every user would want a script to trigger once for every single change made in a directory. At the very least give us a sequential, numeric ID on each message sent by the Directory Watch Trigger such that we can use a Filter to keep only the message where Sequential ID = 1. This behavior really baffles me.


Reply