Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAT300 Notification Services Programming: Introduction DAT300 Notification Services Programming: Introduction Tete Mensa-Annan Program Manager SQL Server.

Similar presentations


Presentation on theme: "DAT300 Notification Services Programming: Introduction DAT300 Notification Services Programming: Introduction Tete Mensa-Annan Program Manager SQL Server."— Presentation transcript:

1 DAT300 Notification Services Programming: Introduction DAT300 Notification Services Programming: Introduction Tete Mensa-Annan Program Manager SQL Server Microsoft Corporation

2 Focus of this session Goal: Goal: – Explain Notification Services concepts and features Non-Goal: Non-Goal: – Teach how to develop Notification Applications

3 Agenda What is SQL Server Notification Services What is SQL Server Notification Services – Introduction Architecture Architecture – Under the hood Instances, Applications, Versioning Instances, Applications, Versioning – Important concepts Deployment Deployment – Scenarios

4 What is the SQL Server Notification Services Platform? A platform for developing and deploying highly scalable, rich Notification Applications A platform for developing and deploying highly scalable, rich Notification Applications A rich yet simple declarative model used to describe Notification Applications A rich yet simple declarative model used to describe Notification Applications An efficient and scalable server, based on SQL Server 2000 and.NET Framework, that execute Notification Applications An efficient and scalable server, based on SQL Server 2000 and.NET Framework, that execute Notification Applications – You write Notification Application - Notification Services hosts and executes it

5 Notification Applications A new class of scalable applications that enable new scenarios delivering personalized and timely information to any device. Personal Any device Timely

6 Notification Applications Events (thousands) Notifications (millions) Match Subscriptions (millions)

7 ActivityGenerationDeliveryReceipt SQL Server on Windows, Oracle on Solaris, DB2 on S/390. Custom Data Store. SQL Server 2000 Notification Services Exchange Server, WinRTC, SMS Aggregator, Custom Mechanism. Outlook, XP Messenger, Pocket PC, SmartPhone 2002, SMS capable phone, Custom Mechanism. Information flow Generation vs. Delivery

8 Why Notification Services? Build and deploy application quickly (Time To Market) Build and deploy application quickly (Time To Market) – You customize within Notification Services framework – You focus on application, not platform design Richness Richness – TimeZones, Recurrence, Fall behind, Retry Performance Performance – SQL matches Events and Subscriptions efficiently – A true ‘Internet’ scale solution

9 Agenda What is SQL Server Notification Services What is SQL Server Notification Services – Introduction Architecture Architecture – Under the hood Instances, Applications, Versioning Instances, Applications, Versioning – Important concepts Deployment Deployment – Scenarios

10 Subscription Management Application Subscriptions Subscribers Custom Event Collector Event Provider Host File System SQL Server Notification Generator SQL Match Rules CustomFormatter Distributor SMS Email File Custom Events Notifications Event Batches Notification Batches Subscriber Devices App. specific Standard XSLTFormatter Architecture Overview

11 Architecture Details Subscription Management Application

12 Allows subscribers to manage subscriptions Allows subscribers to manage subscriptions Can be written in: Can be written in: – Managed code: ASP.NET, C#, VB.Net, etc – Unmanaged code: ASP, C++, VB6, etc

13 Deal with three classes Deal with three classes – Subscriber Represents who gets information Represents who gets information Usually one entry per person Usually one entry per person – Subscription Represent what & when information is sent Represent what & when information is sent Multiple subscriptions per subscriber Multiple subscriptions per subscriber – SubscriberDevice Represents where to send the information Represents where to send the information Multiple devices per subscriber Multiple devices per subscriber Subscription Management Application

14 Architecture Details Event Providers

15 Event Providers collect data changes and submits them as Events in Event Batches Event Providers collect data changes and submits them as Events in Event Batches Notification Applications have one or more Event Provider Notification Applications have one or more Event Provider Event Providers map to Event Classes Event Providers map to Event Classes Notification Services ship with two standard providers Notification Services ship with two standard providers – File System Watcher Event Provider – SQL Server Event Provider

16 Custom Event Providers Hosted Event Provider Hosted Event Provider – Run in-proc with Notification Services Windows Service – Must implement IEventProvider or IScheduledEventProvider interfaces – Less custom code by leveraging Initialize, Run, Terminate, Schedule – Starts and Stops with Notification Services Windows Service Non-Hosted Event Provider Non-Hosted Event Provider – Can run on alternate platform or remote system – Starts and Stops independently from Notification Services Windows Service Event Submission Methods Event Submission Methods – Event Object – XMLLoader Object – Event Submission SQL Server Stored Procedures

17 A Custom Event Provider A Custom Event Provider – Accepts event data from an external source – Creates and populates an event object with event data – Calls Event Collector “Write” for each event – Calls Event Collector “Commit” to submit the batch of events Events events WriteWriteWriteCommit Provider Host EventCollectorCustom Event Provider Event IBM102 ½ MSFT65 ¼ ORCL 8 ¼ IBM 102 ½ MSFT 65 ¼ ORCL 8 ¼ Event Object Submissions

18 XMLLoader Object Submissions A Custom Event Provider A Custom Event Provider – Accepts event data from an external source – Creates an XMLLoader object; optionally initialized with SQL annotated XML event schema – Called with an XML document or stream Batch size = the number of events within the document or stream Batch size = the number of events within the document or stream Events events LoadXML Provider Host XMLEventProvider

19 Event Submission SQL Server Stored Procedures Un-Hosted Custom SQL Server Stored Procedures Provider: DECLARE @eventQuery DECLARE @postQuery SET @eventQuery = SELECT stocksymbol, stockprice from RDT1 UNION SELECT stocksymbol, stockprice from RDT2 SET @postQuery = DELETE RDT1 DELETE RDT2 EXEC NSEventSubmitBatchStockEvent @providerName, @eventQuery, @postQuery Events Submit SQL Stored ProcProvider Raw Data Table 1 Raw Data Table 2

20 SQL Event Stored Procedures Event Class stored procedures Event Class stored procedures – Created per application via ‘nscontrol create’ – Write stored proc defined by the ADF event schema Procedures: Procedures: – NSEventSubmitBatch – NSEventSubmitBatch ProviderName, EventsQuery, PostQuery ProviderName, EventsQuery, PostQuery – NSEventBeginBatch – NSEventBeginBatch ProviderName, out BatchId ProviderName, out BatchId – NSEventWrite – NSEventWrite BatchId, Column1, Column2, etc. BatchId, Column1, Column2, etc. – NSEventFlushBatch – NSEventFlushBatch BatchId BatchId

21 Architecture Details Generator

22 Generator Matches events and subscriptions to produce notifications Matches events and subscriptions to produce notifications You write “match rules” with full power of SQL (Transact-SQL, sp, transactions…) You write “match rules” with full power of SQL (Transact-SQL, sp, transactions…) MatchRule Generator SELECT Notify( S.SubscriberId,S.DeviceName,S.Locale,S.Symbol, E.Price) FROM StockEvents E, StockSubscriptions S WHERE E.Symbol = S.Symbol AND E.Symbol = S.Symbol AND E.Price >= S.TriggerPrice E.Price >= S.TriggerPrice Subscribers Stock Subscriptions Subscriber Devices Stock Events Stock Notifications

23 Rule Classifications Notification generation rules Notification generation rules – Subscription Event rules Multiple per Event Class Multiple per Event Class Multiple per Subscription Class Multiple per Subscription Class Notify when MSFT stock price goes above 70.00 Notify when MSFT stock price goes above 70.00 – Subscription Scheduled rules Multiple per Subscription Class Multiple per Subscription Class TimeZone TimeZone Recurrence Recurrence Send MSFT stock price at 1PM Mon-Fri Send MSFT stock price at 1PM Mon-Fri Chronicle state change rules Chronicle state change rules – Event Chronicle Rule One per event class One per event class Used to maintain Event state like Latest stock prices Used to maintain Event state like Latest stock prices – Subscription chronicle updates (usually embedded within Event & Scheduled Subscription Rules) (usually embedded within Event & Scheduled Subscription Rules) Last time document changes were sent to subscriber Last time document changes were sent to subscriber

24 Rule Firing Sequence Rules firings Rules firings – Event Chronicle Rules Fired first – Subscription Event Rules fired second (Subscription Chronicle Updates) – Subscription Scheduled Rules fired third (Subscription Chronicle Updates) Two in-order application processing options: Two in-order application processing options: – Quantum ordering All event batches for quantum processed first All event batches for quantum processed first All scheduled subscriptions processed second All scheduled subscriptions processed second Never do more work than one Quantum worth at a time Never do more work than one Quantum worth at a time – Strict event batch ordering Scheduled subscriptions due before event batch arrival are processed first Scheduled subscriptions due before event batch arrival are processed first Event batch is processed Event batch is processed Scheduled subscriptions due after event batch arrival are processed until end of Quantum Scheduled subscriptions due after event batch arrival are processed until end of Quantum

25 Generator Falling Behind Generator schedule = Quantum Generator schedule = Quantum Application configurable Quantum limits Application configurable Quantum limits – Event Chronicle Rule firing limit Don’t process stock event batches older than 24hrs Don’t process stock event batches older than 24hrs Don’t process news stories older than 12 hours Don’t process news stories older than 12 hours Don’t process traffic events older than 2 hours Don’t process traffic events older than 2 hours – Subscription Rule firing limit Don’t fall behind more than 15 minutes for basketball notifications Don’t fall behind more than 15 minutes for basketball notifications Don’t fall behind more than half hour on weather notifications Don’t fall behind more than half hour on weather notifications Don’t fall behind more than 20 minutes on traffic events Don’t fall behind more than 20 minutes on traffic events

26 Architecture Details Distributor

27 Distributor Formats and delivers Notifications Formats and delivers Notifications – Transforms Notification using XSLT or Custom Content Formatter module – Applies device, country and region metadata to format the notification body and envelope – Sends the Notification via a delivery protocol Notifications Distributor SMS SMTP SMS Custom Content Formatting

28 Distributor Overview Generator Creates Notifications Generator Creates Notifications – Per Notification Class – Raw notifications as rows in SQL tables Distributor Loop Distributor Loop – Periodically scan for notification batches ready to be distributed – Format raw SQL notification data – Assemble formatted notifications into protocol packets – Deliver the protocol packet – Handle delivery failures

29 Content Formatting Format raw SQL Notification data Format raw SQL Notification data – Language-ContryRegion and DeviceType Specified per NotificationClass Specified per NotificationClass – Stock notifications are formatted differently from Flight notifications Built-in XSLT Content Formatter Built-in XSLT Content Formatter – Applies a XSLT to Notifications Custom Content Formatter Custom Content Formatter – Must implement IContentFormatterInterface – Initialize, ContentFormat, Close methods

30 Digest and Multicast Digest: several individual notifications for the same subscriber are combined into one Digest: several individual notifications for the same subscriber are combined into one – E.g. Stock notifications for MSFT, IBM, CSCO,… for a single subscriber are combined to be sent as one notification – Enabled per notification class – Customer Satisfaction Multicast: same notification sent to multiple subscribers Multicast: same notification sent to multiple subscribers – E.g. Weather report for Seattle is the same for all recipients – Enabled per notification class – Formatting is done once – Underlying protocol can choose to physically send one message, or to send each message separately – Huge performance gain for distributor

31 Retry Logic Handling delivery failures: If a delivery operation fails, the distributor can make multiple attempts Handling delivery failures: If a delivery operation fails, the distributor can make multiple attempts The developer specifies the retry schedule per notification class (per protocol) The developer specifies the retry schedule per notification class (per protocol) – Series of delay intervals Retry attempts will continue until the entire retry schedule has been completed, or until the notification expires Retry attempts will continue until the entire retry schedule has been completed, or until the notification expires Notification is flagged as done and failed if all retry attempts fail Notification is flagged as done and failed if all retry attempts fail – Vacuuming cleans up both successful and failed notifications

32 Agenda What is SQL Server notification Services What is SQL Server notification Services – Marketing Fluff Introduction Architecture Architecture – Under the hood Instances, Applications, Versioning Instances, Applications, Versioning – Important concepts Deployment Deployment – Scenarios

33 Notification Services Instance An Instance hosts one or more Notification Applications that share Subscribers An Instance hosts one or more Notification Applications that share Subscribers Each Instance runs as a multithreaded Windows Service Each Instance runs as a multithreaded Windows Service – Hosts Event Providers, Generator, Distributor Multiple Instances per computer Multiple Instances per computer – Test and production – Separate Windows Services, Databases, trust boundaries Instance may span multiple computers Instance may span multiple computers – E.g., multiple Distributors NewsStockSports Subscribers Internet01

34 Notification Application An Notification Application defines An Notification Application defines – One or more Event Classes, Subscription Classes (Rules), and Notification Classes Each Notification Application is a separate SQL Server database Each Notification Application is a separate SQL Server database – Event, Subscription, Chronicle and Notification data System Elements System Elements – Event Providers (input), Generator (rule evaluation), Distributors (output)

35 Notification Services Versioning Different Notification Services Instances running on the same system may run different versions of Notification Services Different Notification Services Instances running on the same system may run different versions of Notification Services Each Notification Services Instance must run the same version across all computers Each Notification Services Instance must run the same version across all computers Multiple versions of Notification Services may be installed side-by-side Multiple versions of Notification Services may be installed side-by-side Installation of a new version does not remove or replace existing versions Installation of a new version does not remove or replace existing versions

36 Agenda What is SQL Server notification Services What is SQL Server notification Services – Marketing Fluff Introduction Architecture Architecture – Under the hood Instances, Applications, Versioning Instances, Applications, Versioning – Important concepts Deployment Deployment – Scenarios

37 Core Deployment Scenarios

38 Security Designed with Security in mind Designed with Security in mind – Windows Authentication – SQL Server Authentication Typical Accounts (low privileges) Typical Accounts (low privileges) – Notification Services Windows Service Account Domain\NSService + SQL Server NSService Login Domain\NSService + SQL Server NSService Login – SQL Server Service Account Domain\SQLService Domain\SQLService – ASPNET Account Domain\ASPNET + SQL Server ASPNET Login Domain\ASPNET + SQL Server ASPNET Login DBA AccountOperations Account DBA AccountOperations Account Domain\DBADomain\Ops Domain\DBADomain\Ops

39 Summary Notification Services is a platform Notification Services is a platform Enables rapid development of robust scalable Notification Applications Enables rapid development of robust scalable Notification Applications Easy to use Declarative Programming Model Easy to use Declarative Programming Model A True.Net Enterprise Server Product A True.Net Enterprise Server Product

40 Questions and Answers

41 Don’t forget to complete the on-line Session Feedback form on the Attendee Web site https://web.mseventseurope.com/teched/ https://web.mseventseurope.com/teched/

42


Download ppt "DAT300 Notification Services Programming: Introduction DAT300 Notification Services Programming: Introduction Tete Mensa-Annan Program Manager SQL Server."

Similar presentations


Ads by Google