Partilhar via


Defining a File System Watcher Event Provider

To use the file system watcher event provider, you must define a hosted event provider in the application definition, and you must develop a Transact-SQL annotated XML schema file that maps the event data to event fields.

Properties

Use the following guidelines when defining the properties of the file system watcher event provider.

  • ProviderName (required) must be a unique name within your application.
  • ClassName (required) must be FileSystemWatcherProvider.
  • Do not use the AssemblyName property. Notification Services looks in the Microsoft.SqlServer.NotificationServices.dll assembly for standard event provider information.
  • SystemName (required) usually is the name of the computer that will run this hosted event provider. For more information, see Defining Hosted Event Providers.
  • Do not define a timeout value. The file system watcher event provider has its own timeout and retry logic.
  • Do not define a schedule. The file system watcher event provider is a continuous event provider and does not support a schedule.

Arguments

The file system watcher event provider has seven named arguments that are used as initialization parameters. You can specify them in any order:

  • WatchDirectory (required) specifies the full path and name of the directory that the event provider monitors as its value. Either standard or Universal Naming Convention (UNC) naming conventions can be used.

  • EventClassName (required) specifies the name of the event class for which this event provider submits events.

  • SchemaFile (required) specifies the full path to a file containing the Transact-SQL annotated XML schema used to transform the XML file data into the appropriate event format. For more information, see File Validation.

    Note

    The Transact-SQL annotated XML schema provided in the SchemaFile argument must handle all of the fields defined in the event class. If an event field is missing from the schema file, the file system watcher event provider fails with the error, "80004005: the statement has been terminated", and an .err file is created in the watch directory.

  • RetryAttempts (optional) specifies how many times to attempt to access a locked file before removing the file from the queue. This value is an integer with a default value of 10. For more information, see File Pickup and Retry Logic.

  • RetryQueueOccupancy (optional) specifies how many files can be in the retry queue at the same time. This value is an integer, with a default of 1024.

  • RetryPeriod (optional) specifies how often the event provider should process the queue. The value is in milliseconds and specifies the period between when a thread ends and when a new thread begins. This value is an integer with a default value is 10000 milliseconds, which is 10 seconds. A value of 0 results in a single retry attempt when the provider starts.

  • RetryWorkload (optional) specifies the maximum number of files in the queue that can be processed during a single retry period. This value is an integer, with a default value of 1024.

For more information about defining a hosted event provider, see Defining Hosted Event Providers.

Example: File System Watcher Event Provider Definition

The following example shows how to define a file system watcher event provider named StockWatcher in an application definition file (ADF):

<Providers>
   <HostedProvider>
      <ProviderName>StockWatcher</ProviderName>
      <ClassName>FileSystemWatcherProvider</ClassName>
      <SystemName>NSSERVER01</SystemName>
      <Arguments>
         <Argument>
            <Name>WatchDirectory</Name>
            <Value>C:\StockInfo\NewEvents</Value>
         </Argument>
         <Argument>
            <Name>EventClassName</Name>
            <Value>StockEvents</Value>
         </Argument>
         <Argument>
            <Name>SchemaFile</Name>
            <Value>C:\Schemas\StockEventSchema.xsd</Value>
         </Argument>
         <Argument>
            <Name>RetryAttempts</Name>
            <Value>15</Value>
         </Argument>
         <Argument>
            <Name>RetryQueueOccupancy</Name>
            <Value>100</Value>
         </Argument>
         <Argument>
            <Name>RetryPeriod</Name>
            <Value>50000</Value>
         </Argument>
         <Argument>
            <Name>RetryWorkload</Name>
            <Value>100</Value>
         </Argument>
      </Arguments>
   </HostedProvider>
</Providers>

See Also

Concepts

File Pickup and Retry Logic
File Validation

Other Resources

File System Watcher Event Provider
Defining Event Providers
Standard Event Providers

Help and Information

Getting SQL Server 2005 Assistance