SunQuest
 
       MS SQL Server
  Home arrow MS SQL Server arrow Delving Deeper into Notification Services
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Delving Deeper into Notification Services
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-03-15

    Table of Contents:
  • Delving Deeper into Notification Services
  • Creating a Delivery Channel
  • Creating an Event Class
  • Creating a Subscription Class and Subscription Event Rule

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Delving Deeper into Notification Services


    (Page 1 of 4 )

    In this second part of a multi-part article covering the Notification Services framework, you will learn how to create a Notification Services instance and application, a delivery channel, and more. It is excerpted from chapter 18 of the book Programming SQL Server 2005, written by Bill Hamilton (O'Reilly, 2006; ISBN: 0596004796). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    Creating a Notification Services Instance and Application

    The Notification Services instance named StockWatch and a Notification Services application named StockWatchApp are created in theMain()method of Example 18-1. The code follows—the code that creates the Notification Services instance and application is highlighted:

      static void Main(string[] args)
      {
        
    Server server = new Server("(local)");

                              


                     Figure 18-8.  StockWatch notification email

         // create a new instance
        NotificationServices ns = server.NotificationServices;
        nsi = new Instance(ns, "StockWatch");

        CreateDeliveryChannel(); 

        // create a new application in the StockWatch instance
        a = new Application(nsi, "StockWatchApp");
        a.BaseDirectoryPath = baseDirectoryPath;

        CreateEventClass();
        CreateSubscriptionClass();
        CreateNotificationClass();
        CreateHostedEventProvider();
        CreateGenerator();
        CreateDistributor();
        CreateVacuumSchedule();
     

        a.QuantumDuration = new TimeSpan(0, 0, 15);
        a.PerformanceQueryInterval = new TimeSpan(0, 0, 5);
        a.SubscriptionQuantumLimit = 1;
        a.ChronicleQuantumLimit = 1;
        a.VacuumRetentionAge = new TimeSpan(0, 0, 1);

        nsi.Applications.Add(a);

        Console.WriteLine("Added application.");

       
    nsi.Create();
        nsi.RegisterLocal(serviceUserName, servicePassword);
        nsi.Enable();

        Console.WriteLine("Application enabled." + Environment.NewLine); 

        CreateSubscriber();
       
    CreateSubscription();

        Console.WriteLine(Environment.NewLine + "Press any key to continue.");
       
    Console.ReadKey();
      }
     

    TheNotificationServicesobject represents a Notification Services server. TheInstancesproperty of theNotificationServices class returns anInstanceCollectionobject containing a collection of Notification Services instances asInstance objects. At a minimum, you must define aDeliveryChannel object and anApplicationobject to create anInstanceobject—in this example, this is done by theCreateDeliveryChannel()andMain()methods.

    TheRegisterLocal()method of theInstance class registers an instance of Notification Services on the local computer. This is the same as registering a Notification Services instance using SQL Server Management Studio by right-clicking the Notification Services instance and selecting Tasks -> Register from the context menu. You can also register a Notification Services instance by using thenscontrol registercommand. Registering an instance creates or updates registry entries for the instance, creates performance counters, and optionally creates a Windows Service to run the instance.

    TheEnable()method of theInstanceclass enables all instance and application components, allowing event collection, notification generation, notification distribution, and subscription management. ANotificationServicesinstance is disabled when you create it.

    The NMO classes used to manage Notification Services instances are described in Table 18-1.

    Table 18-1. NMO classes for managing Notification Services instances

    Class Description
    Instance Represents a Notification Services instance.
    InstanceCollection Represents a collection of instances asInstanceobjects. TheInstancesproperty of the NotificationServicesclass returns the Notification Services instances on the server.

    TheApplicationobject represents a Notification Services application. At a minimum, you must define aGeneratorobject and aDistributorobject for anApplicationobject—in this example, this is done by theCreateGenerator()andCreateDistributor()methods.

    This example configures theApplicationobject by setting the following properties:

    BaseDirectoryPath
      
    Specifies the base directory path for the ADF

    QuantumDuration
      
    Specifies how frequently the generator tries to
       process work

    PerformanceQueryInterval
      
    Specifies how frequently the application updates its
       performance counters

    SubscriptionQuantumLimit
      
    Specifies how far the logical clock can fall behind the
       real-time clock before skipping subscription rule
       firings

    ChronicleQuantumLimit
      
    Specifies how far the logical clock can fall behind the
       real-time clock before skipping event chronicle firings

    VacuumRetentionAge
      
    Specifies the minimum age at which event and
       notification data is considered obsolete and can be
       removed

    The NMO classes used to manage Notification Services applications are described in Table 18-2.

    Table 18-2. NMO classes for managing applications

    Class Description
    Application Represents a Notification Services application.
    ApplicationCollection Represents a collection of Notification Services applications asApplicationobjects. The Applicationsproperty of theInstanceclass returns the Notification Services applications hosted on the Notification Services instance.

    More MS SQL Server Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming SQL Server 2005," published by...
       · I found this article very useful in tying together many aspects of Web development...
       · I'm glad you found it helpful; thanks for commenting!
     

    Buy this book now. This article is excerpted from chapter 18 of the book Programming SQL Server 2005, written by Bill Hamilton (O'Reilly, 2006; ISBN: 0596004796). Check it out today at your favorite bookstore. Buy this book now.

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway