Lesson 9: Registering, Enabling, and Starting the Instance

In this lesson, you will configure security for the instance of Notification Services and register the instance of Notification Services that installs the Notification Services engine. Then, you will enable and start the instance.

The Notification Services Engine

Earlier in this tutorial, you configured a generator and a distributor for the application. These components are run by the Notification Services engine. If the application had used a hosted event provider, that event provider also would be run by the Notification Services engine.

The Notification Services engine is either a Windows service that you create when you register the instance on a computer, or a process hosted by a custom application.

When you configure hosted event providers, generators, and distributors in the application definition file (ADF), you specify a system name, which is the computer where that component runs. You must install and run the Notification Services engine on each computer specified by the system name values in the ADF.

When you start the Notification Services engine, it connects to the instance and application databases to determine what components it runs and if those components are enabled. The engine then runs its enabled components.

For more information about the Notification Services engine, see Controlling Instance and Application Operation.

The Notification Services engine connects to the instance and application databases and runs its stored procedures. To run these stored procedures, the engine must have login access to the server and the correct database permissions. These permissions are granted to the login through membership in database roles in the instance and application databases. For more information, see Configuring SQL Server Permissions for an Instance of Notification Services.

The Engine for the Weather Application

For this tutorial, you will run the Notification Services engine as a Windows service. You will install the Windows service, named NS$Tutorial, when you register the instance of Notification Services. You will register the instance locally. This is the same computer name you provide for the _NSServer_ parameter when you create or update the instance of Notification Services.

When you register the instance, you must provide a Windows user name and password. The Windows service can use its Windows account or a SQL Server login you specify to log in to the database server. You must add a user for the Windows account or SQL Server login to the TutorialNSMain and TutorialWeather databases and then add the user to database roles. You use this same account when you register the instance of Notification Services. For more information about the security model, see Security Considerations for Notification Services.

After you register the instance and configure security, you will enable and start the instance of Notification Services.

Configure Database Permissions for the Windows Service

Use the following steps to configure database permissions for the account used by the Windows service to connect to the TutorialNSMain and TutorialWeather databases.

To configure database permissions for the Windows service

  1. Choose a Windows account for the NS$Tutorial Windows service.

    When you deploy an instance of Notification Services, use an account that has few privileges, and then grant only the necessary permissions to that account.

  2. If you can use Windows Authentication, make sure this Windows account can log in to the database server. If you cannot use Windows Authentication, make sure there is a SQL Server login that the Windows service can use.

    To add a new login in Object Explorer, expand Security, right-click Logins, and select New Login. You can add Windows accounts or create SQL Server login accounts using this dialog box.

  3. Using Object Explorer, create a database user for the login in the TutorialNSMain database and make the user a member of the NSRunService database role:

    1. Expand Databases, and then expand the TutorialNSMain database.
    2. Right-click Security, point to New, and then select User.
    3. In the User name box, enter a name for the database user.
      The database user name is typically the same as the login name.
    4. In the Login name box, enter the name of the login that is used by the NS$Tutorial Windows service.
      The login name must exactly match the name of an existing login in the instance of the Database Engine. Click the browse (...) button to search for the login name.
    5. In the Database role membership box, click NSRunService.
    6. Click OK.
  4. Create a database user for the login in the TutorialWeather database, and make the user a member of the NSRunService database role:

    1. Expand the TutorialWeather database.
    2. Right-click Security, point to New, and then select User.
    3. In the User name box, enter a name for the database user.
      The database user name is typically the same as the login name.
    4. In the Login name box, enter the name of the login that is used by the NS$Tutorial Windows service.
      The login name must exactly match the name of an existing login in the instance of the Database Engine. Click the browse ( ... ) button to search for the login name.
    5. In the Database role membership box, click NSRunService.
    6. Click OK.

Configure Folder Permissions for the Windows Service

Because the Weather application uses the File delivery protocol to deliver notifications, you must also make sure that the Windows service account has permissions in the folder where it writes notifications.

To configure folder permissions for the Windows service

  1. Open Windows Explorer.

  2. Locate the Notification Services Tutorial folder.

    The default location for this folder is C:\Program Files\Microsoft SQL Server\90\Samples\Notification Services\tutorial.

  3. Expand the Tutorial folder, and then expand the Weather folder.

  4. Right-click the Notifications folder and select Sharing and Security.

  5. On the Security tab, verify that the Windows account used by the NS$Tutorial Windows service has write permissions.

Register the Instance and Create a Windows Service

Use the following steps to register the instance of Notification Services locally and install the NS$Tutorial Windows service. During this step, Notification Services grants Windows permissions to the service account.

Register the instance and create a Windows service

  1. In Object Explorer, expand Notification Services.

  2. Right-click Tutorial, point to Tasks, and select Register.

  3. Select the Create Windows service check box.

  4. Enter the login account and password for the NS$Tutorial Windows service.

  5. If you use SQL Server Authentication to access databases, select SQL Server Authentication and enter the SQL Server login and password. Otherwise, leave Windows Authentication selected.

  6. Click OK to register the instance, create the Windows service, and create performance counters.

  7. When the registration is complete, click Close.

Enable and Start the Tutorial Instance

Use the following steps to enable the Tutorial instance and start the NS$Tutorial Windows service.

To enable and start the tutorial instance

  1. In Object Explorer, right-click Tutorial and select Enable.

  2. Right-click Tutorial, and select Start.

If the service does not start, either the service does not have a valid Windows account, it does not have the necessary permissions, or it cannot connect to the TutorialNSMain or TutorialWeather database. Verify that the account that is used by the service has the permissions that were discussed earlier. For more information, see Securing Notification Services.

Checking Tutorial Instance Status

To verify that the application is configured correctly and that the Tutorial instance is enabled and started, view the status of the Tutorial instance.

To check tutorial instance status

  1. Right-click the instance and select Properties.

    On the Applications page, you can view the status of all application components. In the Current Status column, all components should show Enabled. If the status is Enable Pending, wait 30 seconds and then click Refresh.

    If the status is still Enable Pending, the system name of the component does not match the name of the computer where the Notification Services engine is running. Verify that the Server values on the Application page and the Windows Services page match.

    On the Windows Services page, you can verify that the NS$Tutorial Windows service is running and, in the Associated components box, you can view which components are enabled on the Windows service. You should see one generator and one distributor.

Next Lesson

Even though the Tutorial instance is enabled and running, it will not produce notifications until you have added subscribers, subscriptions, and events. In the next lesson, you will add subscribers and subscriptions.

Lesson 10: Adding Subscribers and Subscriptions

See Also

Concepts

Notification Services Tutorial

Other Resources

Controlling Instance and Application Operation
Securing Notification Services
Building Notification Solutions
Introducing SQL Server Notification Services

Help and Information

Getting SQL Server 2005 Assistance