Directory Watch Publisher
The Directory Watch publisher monitors activity on a Resources folder or other location, and publishes messages about that activity to FME Server topics. Activity can include adding, changing, and deleting files and folders.
Note: You cannot monitor an Amazon Web Services (AWS) S3 bucket with the Directory Watch publisher.
Configuring the Publisher
- In the FME Server Web User Interface, select Notifications > Publications, and click New.
- Provide a name for the Publication
- Protocol: Select Directory Watch.
-
Specify the Topics you want to publish to using the drop-down selector. To create a topic and use it right away, click +.
- Directory to Watch: To watch a Resources directory, click the ellipsis (...), and select a directory to watch. To watch another directory, enter a local file system or network (UNC) path directly in the textbox.
- Watch Subdirectories: To watch activity in the selected directory and all subdirectories, specify Yes. To watch activity only in the selected directory and not in its subdirectories, specify No. This setting also applies to directories that are added into the watched directory. If No, separate notifications are not generated for files in a directory that is added.
- Receive Notification for Folders: If Yes, the publisher monitors activities on both files and folders. If No, the publisher monitors activities on files only.
- Filter: By default, all actions on the specified directory are monitored, including adding (CREATE), changing (MODIFY), and deleting (DELETE) files (and folders, if applicable). To monitor only one or two of these actions, click the "x" beside the action you do not want to monitor to remove it. To add an action after removing it, click inside the dropbox and select it.
- Poll Interval: How often, in minutes, to poll the specified Directory to Watch for activity.
- Initial Action
- Notification
- DELETE actions: A notification is sent after the current poll interval elapses.
- CREATE and MODIFY actions: An additional poll interval occurs. If the action is complete after the additional poll interval, a notification is sent. Otherwise, one additional poll interval occurs, and a notification is sent, whether or not the action is complete.
- Click OK.
Note: The user account that runs the FME Server Core service must have Read/Write (Windows) or Read (Linux) permission on any directories that are not managed as FME Server Resources. See here for information about adding directories as Resources.
Note: Events trigger based on changes in file date. If a file is overwritten, a MODIFY event is triggered.
When an action (CREATE, MODIFY, DELETE) occurs, it enters into the current poll interval, which has partially elapsed.
Note: Sending the notification after a maximum of two additional poll intervals acts as a timeout in case the publisher cannot determine if the action is complete. In some cases, the notification would be considered premature and may cause problems in subsequent workflows. To avoid this situation, the best practice is to set Poll Interval longer than the time required to complete an action.
Note: A CREATE and MODIFY action on the same file within a single poll interval triggers only a CREATE notification. A CREATE, MODIFY, and DELETE action on the same file within a single poll interval triggers no notification.
WARNING: If an FME Server running on Linux watches a mounted Windows drive and a CREATE action occurs, a notification is sent as soon as the first poll occurs, regardless of whether the action is complete. This notification may trigger a subscriber (for example, an FME Workspace subscriber) to use the file before it has completely transferred, causing an error.
Sample Notification Schemas
To parse the incoming JSON message from the Directory Watch publisher, use the Directory Watch Reader custom format in your FME Workbench workspace. For more information and to download the reader, visit the FME Store at fmestore.safe.com/.
When a file is deleted
{
"dirwatch_publisher_path": "C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_content": "ENTRY_DELETE C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_action": "DELETE",
"fns_type": "dirwatch_publisher"
}
When a file is changed (for example, added content)
{
"dirwatch_publisher_path": "C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_content": "ENTRY_MODIFY C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_action": "MODIFY",
"fns_type": "dirwatch_publisher"
}
When a file is added
{
"dirwatch_publisher_path": "C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_content": "ENTRY_CREATE C:\\apps\\FMEServer\\Temp\\sample_file.txt",
"dirwatch_publisher_action": "CREATE",
"fns_type": "dirwatch_publisher"
}