[Top] [All Lists]

Re: Event base notification

Subject: Re: Event base notification
From: Joe Webb
Date: Fri, 29 Apr 2005 08:37:48 -0500
Newsgroups: microsoft.public.sqlserver.notificationsvcs
Hi Balaji -

Creating custom event providers is a wonderful feature in the SQLNS framework. It provides us with great flexibility and allows us to go beyond the FileSystemWatcher and SQLServer event providers that come with SQLNS. Thanks for posting the code!
Just for clarity, there are a couple of points that I'd like to add to
your post.
First, custom event providers are really useful for collecting events
from sources other than an XML file and a database. You can, for
example, develop a custom event provider to gather information from the
AP NewsWire, a propriety CRM package, or even a properly wired coffee
pot so we'll know when there's a fresh pot. :)
Events can be submitted into the SQLNS app at anytime. We can schedule
their occurence (see Defining the SQL Server Event Provider in BOL for
more details), they can be submitted from a trigger or sproc in another
database, or controlled by their own mechanisms.
There doesn't have to be a correlation between the event coming into the
system and the notification that goes out. For event driven
subscriptions, there is that quasi-link that's controlled by the
matching rule, but it for scheduled subscriptions, the link really
doesn't exist. Scheduled subscriptions are evaluated periodically based
on the the QuantumDuration application execution setting. If any
scheduled subscriptions meet the matching rules, notifications are
produced. The weather sample application that comes with SQLNS
demonstrates how to configure scheduled subscriptions.
As I mentioned in another post, scheduled subscription cannot be
scheduled to occur multiple times within a day. To achieve that
frequency, we can create multiple scheduled subscriptions or do like
you've suggested in your post - create event driven subscriptions and
carefully configure their submission.
Thanks again for the post!

Joe Webb
SQL Server MVP

Get up to speed quickly with SQLNS

Balaji Ramachandran wrote:

You need to create your own custom event generators.

/*********Inside the appadf.xml *******/
                        <FieldTypeMods>not null</FieldTypeMods>

Here goes a sample.
Create a new class library project 'MyEventProviderPrj'.
Add the collowing class.

using System;
using System.Collections.Specialized;
using Microsoft.SqlServer.NotificationServices;
using System.IO;

namespace SpiderEvent
        /// <summary>
        /// Summary description for Class1.
        /// </summary>
        public class ScheduledEvent : IScheduledEventProvider
                NSApplication myApplication;
                EventCollector myEventCollector;
                string eventProviderName;
                StringDictionary arguments;
                string logfile= @"C:\temp\eventlog.txt";
                StreamWriter st;

                public ScheduledEvent()
                        FileStream fs= new FileStream(logfile,FileMode.Append);
                        st= new StreamWriter(fs);
                public void Initialize(
                        NSApplication application,
                        string providerName,
                        StringDictionary args,
                        StopHandler stopDelegate )
                        this.eventProviderName = providerName;
                        this.arguments = args;
                        this.myApplication = application;
st.WriteLine("INititialised"+ DateTime.Now.ToString()); //Create the event collector. this.myEventCollector = new EventCollector(myApplication, eventProviderName);

                public bool Run()
                        bool returnValue = true;
                                Event myEvent = new Event();

                                //Create an event to convey the event log data.

                                //Commit the event batch.
                                int eventsSubmitted = myEventCollector.Commit();
                                myEvent = null;
                        catch (Exception /*e*/)
                                //Provide error handling here.
                                st.WriteLine("Error in 
                        return returnValue;

                //Implement the IScheduledEventProvider.Terminate method.
                public void Terminate()

Compile the dll, put it in c:\MyEventProviderPrj.dll.

Now for every 30 mins, your event generator (MyEventProviderPrj.dll) will be called.
Inside the event generator, we are raising an event named 'DailyReportEvent'.

If you create a event based notification, then it will be invoked.

You can adjust the event generation interval in the schedule interval element node.
Also please go thru the readme.txt (under C:\Program Files\Microsoft SQL
Server Notification Services\v2.0.3008.0 ) the following section.
4.15 Using Custom Components Built With Version 1.1.4322 of
 the .NET Framework
And do the necessary changes.

I hope this helps you.


"Mohammed Anees via" wrote:


could somebody help me,

I would like to fire an event schedule wise automatically to all users who
subscribe in particular category.


An event to fire hourly/daily at particular time to all subscriber

how can it possible in SQL Server 200 notification server, if any body have
the sample code or example please mail me at mdaneespm AT hotmail DOT com


Mohammed Anees

<Prev in Thread] Current Thread [Next in Thread>