« Home « Kết quả tìm kiếm

Microsoft SQL Server 2005 Developer’s Guide- P8


Tóm tắt Xem thử

- Developing Notification Services Applications.
- In the first part of this chapter you got an overview of the new SQL Server 2005 Notification Services.
- In this next section, you learn about the actual steps required to develop SQL Server 2005 Notification Services applications.
- First, you’ll see a quick overview of the development process, and next we’ll dive in and build a sample Notification Services application..
- The process for developing Notification Services applications begins with defining the rules that govern how the application works.
- The Notification Services developer uses a combination of XML and T-SQL to define the application’s schema and rules.
- When you define the schema and the rules for a Notification Services application, you are essentially describing the events that the application will monitor as well as the application’s subscriptions, its notifications, and the logic that will be used to match the events to the subscriptions..
- The Notification Services application’s rules are primarily defined in two files—an application definition file and an instance configuration file.
- a Notification Services application is to compile all of the code and register a service that will run the Notification Services applications.
- To compile the application, you can use the Notification Services node in the SQL Server Management Studio or the nscontrol command-line utility.
- These tools create the Notification Services instance and database, if required..
- The first two steps build the core engine of the Notification Services application..
- To enable users to enter their subscription information, the Notification Services application needs a subscription management interface, which is typically a Web or Windows application built using ASP.NET, VB.NET, or C# technologies..
- This application updates entries to the Notification Services subscription database..
- Finally, the last step in building your Notification Services application is to optionally add any custom components that might be needed by the application.
- components would include any required custom event providers, content formats, or notification delivery protocols that are not included in the base SQL Server 2005 Notification Services product..
- Notification Services Application Sample.
- The sample Notification Services application that is presented in the next part of this section represents a simple shipping notification application.
- The user must enter a subscription for that event, and a rule must be added to allow the Notification Services engine to match the events to the subscriptions.
- Now that you’ve got an overview of the sample Notification Services application, let’s see how it’s built..
- Notification Services applications consist of two primary files: an application definition file (ADF) and an instance configuration file (ICF)—both XML files that must be built in accordance with their XSD schemas.
- ADF files are essentially the source code for a Notification Services application..
- The ADF file is the core file for the Notification Services.
- the different sections of the ADF describe the event, subscription, rules, and notification structure that will be employed by the Notification Services application.
- The ICF file defines the name of the Notification Services application as well as its instance name and the application’s directory path.
- The instance name is essentially the name of a Windows service that runs the Notification Services application..
- SQL Server 2005 Notification Services provides two templates that can be used as a starting point for creating your own ADF and ICF files.
- The following listing shows the ICF file, icf.xml, that’s used for this Notification Services sample application:.
- The first section to notice is the Parameters section, which enables you to more easily deploy the Notification Services application to other systems by passing in environment variables to the creation scripts.
- The next section contains the elements that define the Notification Services instance..
- As you might guess, the SqlServerSystem name tag contains the name of the SQL Server system that will host the Notification Services databases, the InstanceName tag defines the instance name for the application, and the ApplicationName tag defines the name of the Notification Services application.
- While the ACF file describes the server and the locations where the application definition files are found, the core definitions that control how a Notification Services application works are described in the ADF..
- The event defines the data that can be submitted to your Notification Services application and is used to generate notifications.
- In the ADF file the EventClasses element contains the XML code that’s used to define the Notification Services events.
- All ADF files must begin with the application elements, which, as you might guess, represent the Notification Services application.
- The Schema section within the EventClass element defines the event schema that the Notification Services application will monitor.
- Notification Services uses these definitions to create a table in the Notification Services database.
- Here you can see the definition for the SQL Server event provider that is used to connect the Notification Services application to SQL Server:.
- The Providers section of the ADF describes the event providers used by the Notification Services application.
- As you saw earlier with the event class, Notification Services uses the subscription class definitions to create database objects like tables, views, indexes, and stored procedures for the subscription class..
- The following code listing shows the next portion of the adf.xml file, which describes the subscriptions used by the sample Notification Services application:.
- As you saw with the event class, Notification Services uses the subscription class descriptions to create database objects when the Notification Services application is generated..
- EventRules element defines the logic that the Notification Services application will use to match events to subscriptions.
- The final part of the ADF file defines the notification as described in the.
- The NotificationClasses describe how the notification information will be delivered.
- In this listing you can see that the notification class is named ShipNotifications..
- Formatting the Notification Output.
- <BR/>Microsoft SQL Server Notification Services </I><BR/><BR/>.
- The style sheet used to format the Notification Services application’s output is a standard XSLT style sheet.
- After the required XML and T-SQL application code has been created, you’re ready to build the Notification Services application.
- Notification Services applications can be created interactively using the SQL Server Management Studio, or they can be created using the nscontrol utility.
- First, you’ll see how to create them using the SQL Server Management Studio, and then you’ll see how you can create Notification Services applications using the nscontrol commands in the batch file..
- Building Notification Services Applications Using SQL Server Management Studio.
- After the icf.xml and adf.xml files that define the Notification Services have been created, you can use them to build your Notification Services application from the SQL Server Management Studio by first opening the Object Browser and right-clicking the Notification Services node.
- Then you can select the New Notification Services Instance option from the context menu to display a screen like the one in Figure 5-3..
- To create a new Notification Services application using the New Notification Services Instance dialog, you click Browse and navigate to the directory that contains your application’s instance configuration file.
- Figure 5-3 The New Notification Services Instance dialog.
- Clicking OK generates the Notification Services application and displays the summary dialog that you can see in Figure 5-4..
- To register the newly created Notification Services application, open the SQL Server Management Studio and then, in Object Explorer, expand the Notification Services node.
- Right-click the name of your Notification Services application.
- This will register the Notification Services instance, create the Windows service, and create a set of performance counters for the application..
- Figure 5-5 illustrates registering the Notification Services application..
- After the Notification Services application has been registered, you can go ahead and start the application.
- To do so, go to SQL Server Management Studio, open Object Explorer, and navigate to the Notification Services node.
- Figure 5-4 The Notification Services Creation Status dialog.
- If the Notification Services application doesn’t start, the most likely problem is the account used by the Notification Services Windows service.
- Check to make sure you are using a valid account and it has permissions to access the Notification Services databases.
- Building Notification Services Applications Using nscontrol.
- As an alternative to using the SQL Server Management Studio to create Notification Services applications, you can use the nscontrol commands.
- A command-line tool that’s used to create and administer Notification Services applications, nscontrol Figure 5-5 Registering the Notification Services application.
- understands a number of different action commands that you can use to work with Notification Services applications.
- Creating a Notification Services application is a multistep process.
- This creates the database used by the Notification Services application.
- The following batch file illustrates the command sequence needed to create the example NSSample Notification Services application:.
- nscontrol create Creates a Notification Services application and its databases..
- nscontrol delete Deletes a Notification Services application and its databases..
- nscontrol disable Disables a Notification Services application..
- nscontrol enable Enables a Notification Services application..
- nscontrol listversions Displays the version of Notification Services and any registered applications..
- nscontrol register Registers a Notification Services application..
- nscontrol status Displays the status of a Notification Services application..
- nscontrol unregister Unregisters a Notification Services application..
- nscontrol update Updates a Notification Services application..
- The nscontrol create command’s –in argument specifies the name of the Notification Services ICF.
- Running the nscontrol create command creates two databases on the server, NSSampleInstanceMain and NSSamp leInstanceNSSample, which store the Notification Services application definition and data events..
- The nscontrol register command uses the –name argument to identify the instance name of the Notification Services application to register.
- Updating Notification Services Applications.
- Like all other applications, Notification Services applications need to be updated and changed from time to time.
- To re-create the Notification Services application, you could delete the entire application instance and then re-create, enable, and register the application.
- Instead, to update a Notification Services application, you can make changes to your application definition file and then save those changes.
- Next, open up SQL Server Management Studio and then use Object Explorer to navigate to your Notification Services application listed under the Notification Services node.
- As you may have guessed, you can also update a Notification Services application using the nscontrol commands..
- While the core logic of a Notification Services application is defined using the ICF and the ADF files, subscribers, devices, and subscriptions are typically created by client applications that use the Notification Services API.
- You can see an example Notification Services client application in Figure 5-6..
- The sample application shown in Figure 5-6 adds subscribers, devices, and subscriptions to the Notification Services application using the Subscribers tab.
- Client applications connect to Notification Services using the managed code APIs that Microsoft provides with SQL Server 2005 Notification Services.
- While the Notification Services API is provided via managed code classes, you can also access the API from unmanaged code by using Win32-based COM applications..
- The Notification Services API is located in Microsoft.SqlServer.NotificationServices .dll, which must be added to your .NET project as a reference.
- Then you can use the Notification Services classes to manage subscriptions to your Notification Services applications.
- To add a reference to the Notification Services API, select the Project | Add Reference menu option to display the Add Reference dialog

Xem thử không khả dụng, vui lòng xem tại trang nguồn
hoặc xem Tóm tắt