Home > Articles > Databases > SQL Server

Notification Services and the Service Broker in SQL Server 2005

Buck Woody
  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close WindowBuck Woody

Buck Woody

Learn more…

If it's Free it's for Me
By on January 26, 2009 No Comments

Sign me up for anything free these days. I just ran across a book that promises to help you build a web site for free...

Not stressing about the job
By on January 10, 20094 Comments

You know, I think that the media shares a HUGE part of the blame for the economy. They screamed "things look bad!" so much that the general public got spooked and quit spending, thinking the worst. That leads to a spiral where people don't buy what you sell, and things DO get bad.  

Cost Cutting and the DBA
By on December 19, 20083 Comments

It seems all the news can talk about is the "bad economy". Personally, I think they have talked a lot of people into panic mode, which has in fact made any kind of slowdown even worse. But hey, whatever sells TV ad time, right?

So since the public has so heartily embraced the news' view of the world, business has in fact slowed down. And it seems that the business wants everyone to cut costs. So what can the DBA do?

Working with multiple platforms
By on December 18, 2008 No Comments

I've worked with more than one database system, as I'm sure many of you have as well. It seems to be common among Microsoft SQL Server DBAs to have done that.

Monitoring the Spaghetti
By on December 16, 2008 No Comments

With the new Management Data Warehouse in SQL Server 2008 and all the new meta-data, I get a lot of monitoring out of the box. But sometimes I need more...

SQL Server Forensics
By on December 8, 2008 No Comments

I'm a big proponent of security for SQL Server. There are many parts to security, as I've explained in many of my articles and posts. But there is one area that a lot of SQL Server professionals might not be aware of - forensics.

Conferences and Alternatives
By on November 24, 2008 No Comments

I've been a little busy lately, and most of it is due to conferences. I present at quite a few of them around the world, and lately I've heard from a few of my DBA friends that they aren't always able to get to conferences lately.

So help me Codd
By on November 5, 20083 Comments

The way I learned about database normalization was to memorize the statement "The Key, The Whole Key, and Nothing but the Key, so help me Codd". I normally (get it?) take a database ddesign to third normal form and them go back and de-normalize it back to something that works for my requirements.

PowerShell and SQL Server
By on October 31, 2008 No Comments

I wrote a series of articles sometime back on PowerShell and SQL Server. The first series was on using the SMO provider for SQL Server access, and the second was on using the new SQL Server 2008 "native" provider that is far easier.

Gaps in the DBA
By on October 20, 2008 No Comments

I've seen most DBAs come from two directions: system administrators that take care of databases, and developers who take care of databases. I've rarely met a "trained" DBA - one who has only ever worked with databases.

Do DBAs have to know SQL?
By on October 11, 2008 No Comments

Most DBAs know how to work with the SQL Language, although some DBAs I know do a whole lot more administration than programming. For those folks, there's usually a developer involved that takes care of everything on the programming side. The DBA takes care of the hardware, backups, that sort of thing.

Data Modeling
By on October 4, 20082 Comments

I teach a course on Wednesday nights at the Univeristy of Washington on Database Technology. The way I arrange my class is to start with a project, and then work my way through the project applying the database technologies along the way.

Another reminder about keeping your job in tough economic times
By on September 30, 2008 No Comments

Seems like history keeps repeating itself - the markets are tumbling, and people are nervous about their finances. Your job is your lifeline - and you should know how to keep yours.

DBAs and Admins
By on September 22, 2008 No Comments

I was talking with a developer friend today about how I used to work on Oracle as opposed to how I work with SQL Server.

Did you know that the + sign is Unicode? Me either...
By on September 8, 2008 No Comments

I was working with an application today that had an "Execute SQL Function", only I couldn't get it to work. I finally talked with the developer, and she told me that it was really using sp_executesql under the covers, although they re-wrapped it a bit.

Social Networking for the DBA/Developer
By on September 1, 20082 Comments

I'm on a few social networking sites, like LinkedIn, but I'll be honest that I'm not very active on them. It certainly isn't because I'm not technology-driven - I'm at my PC all day.

More to read on LINQ
By on August 28, 2008 No Comments

As you may have heard, Microsoft has released a new way of querying data. This new language extension, called LINQ, is aimed mostly at the developer, but it doesn't hurt for DBAs to be aware of it either.

The CLR in SQL Server
By on August 20, 2008 No Comments

There's a new podcast here at InformIT that you should check out. If you use the CLR layer in SQL Server, you should check it out.

UNIQUE versus PRIMARY KEY contstraints
By on August 18, 2008 No Comments

If you need to enforce a column to have unique values, there are a couple of choices you have to enforce that. One is the UNIQUE constraint, and the other is to make the column a primary key.

SQL Server 2008 is here!
By on August 6, 2008 No Comments

SQL Server 2008 was released to manufacturing today.

Systems Management
By on August 4, 2008 No Comments

Many SQL Server DBAs are asked to do more than just the database. They are asked to look after multiple kinds of systems, which can be quite a challenge.

Other SQL Server 2008 Downloads
By on July 28, 2008 No Comments

SQL Server 2008 is getting close, so several of you have told me that you're downloading the release candidate.

Clean Code
By on July 19, 2008 No Comments

I've seen a lot of bad code in my day, and one of my favorite parts of the "Communications of the ACM" magazine that I read is "Kode Vicious", a writer who criticizes bad code.

Virtualization is everywhere
By on July 16, 2008 No Comments

I use Virtual Machines all the time - any time I need to develop or test something I fire one up. I used to work with VMWare's products, which I really like. Lately I've been using Microsoft's Virtual PC, but I just saw a new book on Xen, the Open Source VM software.

Tuning starts with design
By on July 14, 2008 No Comments

I've come in to lots of situations to tune a system, only to find that the database design needs work.

Learning the Basics
By on July 3, 2008 No Comments

I was talking with someone today who wanted to refresh the basics on their knowledge of working with SQL.

New things to learn
By on June 30, 2008 No Comments

I love learning new things. I was just speaking with several "geek" friends today about Object-Oriented Databases.

ER Diagraming tools
By on June 23, 2008 No Comments

I've used quite a few products in the past to design databases, from large tools like ERWin to smaller tools like those inside SQL Server itself.

ERD Design
By on June 17, 2008 No Comments

I've used a lot of design tools in my day, but these days I'm just using the diagrams in Visio for database Entity Relationship Diagrams (ERD).

Virtual Machines are a big old deal
By on June 10, 2008 No Comments

I'm at TechEd this week and there are a few things that are catching a lot of buzz. One of them is virtualization.

Heading to Teched
By on June 6, 2008 No Comments

I love going to TechEd. It's hard to beat getting together with 13,000+ of my favorite geek friends.

check your security
By on June 4, 2008 No Comments

I mentioned in a previous post that you should check your applications for SQL Server Injection attacks. That brings up the entire process of security auditing.

SQL Server Injection Attacks and what you can do about them
By on June 2, 2008 No Comments

A SQL Injection attack is simply inserting another statement inside a SQL string. Even though they are simple to construct, they can be difficult to defend against if your code is not set up properly.

Getting Better at Transact-SQL
By on May 26, 2008 No Comments

In a few of my DBA roles, I only used Transact-SQL to work with database objects or to get Meta Data. In others, I was expected to create all Stored Procedures and Dynamic SQL for the entire team.

Watch your code!
By on May 21, 2008 No Comments

Recently SQL Server and its made the news-and not in a good way.

 

The headlines screamed - SQL Server and IIS are hacked! In fact, this was a standard SQL Injection attack - which has nothing specifically to do with IIS  or SQL Server. A SQL Injection attack is a result of not validating user-input, and it works against any DB and application that isn’t written properly.

Using Consultants
By on May 19, 2008 No Comments

From time to time you need help with a project. Perhaps you need more staff for a short period of time, or more often you're taking on a new task that you've never done before.

Timing Your Recovery
By on May 14, 2008 No Comments

If you don’t have a formal plan for your disaster recovery, consider this a gentle reminder. Have a full set of articles here on InformIT that will help you with a complete strategy, but I want to focus on one component: Recovery Time.

Virtually SQL
By on May 13, 2008 No Comments

Are you using SQL Server inside a VM? I do this all the time. It's supported for Microsoft's VM offerings, and I've found the benfits to be huge.

Database Engine Tuning Advisor
By on May 6, 2008 No Comments

You should be using the Database Tuning Advisor, or DBTA, to help you evaluate your system's performance and even your database design. But are you aware that this system needs a little maintenance?

Multi-Vendor Shops
By on April 30, 2008 No Comments

I've worked in a few shops that were all one vendor. Sun hardware, Oracle software, that kind of thing. And I think many of us have worked in all Microsoft shops.

Storage Providers and SQL Server
By on April 28, 2008 No Comments

When I worked with Oracle systems, I found that the storage system was always considered separately from the database engine. This made sense, because some Oracle systems ran on mainframe-like operating systems.

New Support Mechanism
By on April 25, 2008 No Comments

You've probably noticed that Microsoft has changed the process for getting hotfixes and so on for SQL Server. Sometimes that can be a bit confusing, but there's help in the works.

The Mesh is Here
By on April 23, 2008 No Comments

You may have heard that Ray Ozzie, the new Microsoft head, has announced a new direction for the company.

Service Pack 3 for SQL Server 2005 is Announced
By on April 16, 2008 No Comments

Microsoft has announced that there will be another Service Pack for SQL Server 2005.

Backups - Native or Not?
By on April 14, 2008 No Comments

Microsoft has built in a lot of backup functionality into the product - but do you use it?

Open Source Databases and The Web
By on April 2, 20082 Comments

I saw an article today from The 451 Group, a New York-based technology-industry analyst company that stated that most Open Source databases are used in Web settings. I really don't understand that. I've used lots of MySQL and Postgres, and I've simply found SQL Server Express easier to use.

DBAs as a Service
By on March 31, 2008 No Comments

I've been hearing a lot again lately about "outsourced DBAs", and I still haven't seen it work reliably. Well, that's not true - I have seen it work in one way.

Scripting saves the day
By on March 26, 2008 No Comments

I've done a series here on InformIT that talks about scripting and SQL Server. Lately I've been using PowerShell a lot more.

How much middleware do you have to know
By on March 24, 2008 No Comments

Most of us have enough on our hands just keeping the database systems alive and kicking. But these days, if you have a complex system, you're asked to do a little more.

Compliance and Databases
By on March 19, 2008 No Comments

Do you have any extra work these days as part of a "compliance" program at your company? It seems that some of the laws meant to protect us all end up generating nothing but revenue for compliance assistance firms and software.

Jobs are still looking up...for some
By on March 17, 2008 No Comments

I just read another post from the UK which mirrors some of the data I'm seeing for the US, involving jobs for database technology.

Using Windows CE
By on March 14, 2008 No Comments

I normally don't play with the smaller editions of SQL Server, but lately I've been working with SQL Server CE edition.

Time to Update Your Baselines
By on March 10, 2008 No Comments

I've blogged and written before about the importance of taking a baseline on your system...

Uptime is always important
By on March 6, 2008 No Comments

With a database system, it's tough to maintain uptime. Sure, the systems normally run fine, but what about times when you need to take it down?

Have you Benchmarked Today?
By on February 25, 2008 No Comments

I've mentioned in my articles on Performance Tuning that you need to take a Benchmark on your systems so that you have something to compare measurements.

Free e-book on SQL Server 2008
By on February 11, 20082 Comments

Microsoft is making a free offer on a book and three clinics on SQL Server 2008. Here's how you can get yours.

Do you want a web interface?
By on February 1, 2008 No Comments

I'll be honest - I'm still getting used to the idea of using A Visual Studio inspired interface to manage SQL Server.

Databases - The enterprise Junk-Drawer
By on January 28, 2008 No Comments

Everybody has a "junk drawer" in their house. A place where everything ends up, from warranty papers to broken flashlights. For some reason, they just never seem to get cleaned up. Why is that?

Free SQL Server 2005 Performance Reports
By on January 25, 2008 No Comments

There are some fantastic performance reports you can get as an add-in to SQL Server 2005. There are some instructions to follow to get them to work, but it's awesome stuff when you do.

It's about time to check those DR solutions you put in...
By on January 24, 2008 No Comments

I've posted an article or two here at InformIT about Disaster Recovery. It's a great thing to have a plan, but...

Sun buys MySQL
By on January 16, 2008 No Comments

Sun has announced today that they purchased MySQL.

Multiple Tools For a Single Task
By on January 14, 2008 No Comments

Most tasks in SQL Server can be handled with a single tool. But there's at least one task that takes multiple tools - Performance Tuning.

Where have all the samples gone?
By on January 11, 2008 No Comments

The samples for SQL Server used to be delivered right on the CD's, or at least off of the TechNet site. But you're right if you've noticed that those vehicles don't have the samples any more...what gives?

Refactoring your code
By on January 7, 2008 No Comments

Refactoring is the process of examining your Transact-SQL Server statements and performing the same actions in a different way. Now, different doesn't always mean better...

Microsoft changes Windows Web Server Licensing
By on January 4, 2008 No Comments

I used to work at a shop where we sold an application that used Windows, IIS and SQL Server. The big deal was that you had to license Windows for each user that ran the application, even though it was just used as a web front-end. Well, that may have changed a bit.

Minimizing SQL Server Downtime
By on January 2, 2008 No Comments

I figure the two worst problems with a database are corrupt data and an unavailable system. You can follow good coding and referential integrity tips to avoid much of the first problem, and you can implement a few other tips to help with the second.

Is 2008 the year of SOA
By on December 31, 2007 No Comments

I mentioned that many are predicting that Business Intelligence will finally come into its own in 2008. The trouble is, I've heard that every year for the past five years. Now I hear that 2008 will be the year of SOA.

The variety of the DBA job
By on December 28, 2007 No Comments

I've read a couple of articles lately from two different sources. One had to do with a DBA at the research center at the South Pole, and the other was about the DBA's at the Denver International Airport.

Is 2008 really the year of Business Intelligence?
By on December 26, 2007 No Comments

I've seen predictions that 2008 will finally bring Business Intelligence to the forefront of company planning. The trouble is, I've seen that prediction for over five years now.

Company Consolidation
By on December 24, 2007 No Comments

One of the biggest trends in our industry lately is the consolidation of companies. We see IBM, Oracle and Microsoft buying up either specialty companies to fill out their portfolios, to get certain people in the fold, or to remove the competition. Is this a good thing?

Express versus Trial - What's the difference?
By on December 19, 2007 No Comments

I was asked today what the difference between Express Edition and the Trial Edition is.

SQL Server 2008? Or SQL Server 2005?
By on December 17, 2007 No Comments

There are a lot of shops still running SQL Server 2000. Most of the time a company is not in a hurry to upgrade something that is working well for them.

Better than it has to be
By on December 10, 2007 No Comments

I took my daughter to an outdoor ice-skating event that they set up near where we live. As I sat and watched her skate, I noticed the local name-your-group was selling Hot-Chocolate... 

Books Online 2005 September Update is available
By on November 30, 2007 No Comments

I'm using Vista on my laptop, and for some reason I always forget to check the "optional" updates. I did that today and noticed that Books Online for September was available.

PowerShell HTML Converter
By on November 28, 2007 No Comments

I try not to point you off to too many links from this blog and provide original content. But every once in a while I find something really useful that I just need to share. This is one of those times.

Using what you have
By on November 26, 2007 No Comments

It's important to realize that there are a lot of things in SQL Server that are built right in. I've spoken with many DBA's who are working the long way around a problem.

Longhorn Server and SQL Server
By on November 16, 2007 No Comments

I saw onthe Microsoft site today that there is a new CTP announced for "Longhorn" - the next version of Windows server.

Keeping to the basics
By on November 14, 2007 No Comments

David Litchfield is reporting that half a million database servers are sitting vulnerable on the Internet.

IBM Buys Cognos
By on November 12, 2007 No Comments

Well, it's official - after months of speculation, IBM popped down the big money and bought Cognos, a leading supplier of Business Intelligence.

Deprecated Features - Article Pointer
By on November 9, 2007 No Comments

I try to bring in new material (of my own) ever few days here, but every so often I just have to share a link. This is one of those times.

Soft Processes and Hard Software
By on November 7, 2007 No Comments

Sometimes, you can just state the way things should be, and at others, it doesn't work out that way. At most of the shops I've worked at, there are a set of rules and guidelines we followed for table names, when to backups, and other tasks.

More new versions
By on November 5, 2007 No Comments

No, I'm not just talking about SQL Server 2008, although I will be. I'm talking about all the other versions of things that are coming out...

Cycling Error Logs
By on November 3, 2007 No Comments

We recently investigated an issue with the SQL Server Error Logs - the text files that SQL Server and the Agent write to - that were growing by a tremendous amount. Once we located the issue, we faced the problem of the size of the logs.

Google Trends for SQL Server 2K
By on October 31, 2007 No Comments

You can often find out how much adoption there is of a product by using the Google "trends" comparison. It shows a graph of the type of searches done against the two terms.

How many times does it take?
By on October 29, 2007 No Comments

I just heard ANOTHER report on the news about personal data being released into the wild. In this case tens of thousands of records about Navy personnel was actually published on a web site for a while.

SQL Server and HyperThreading
By on October 24, 2007 No Comments

I've been seeing a lot of chatter about SQL Server and hyper-threading processors. The question usually comes up, does HT make things worse or better for SQL Server?

The answer is, of course, it depends. First, a word on hyper-threading. Hyper-threaded processors split calls up so that one processor looks like two. So far, so good, especially for SQL Server. However, just like in real life, nothing is ever free.

Webcast: What I wish every Developer knew...
By on October 22, 2007 No Comments

There's a great webcast over at Microsoft called "what I wish every developer knew about SQL Server'.

They don't make em like they used to
By on October 19, 2007 No Comments

"Deprication" is is a fancy way of saying "We're not including this any more." There are things in SQL Server 2005 that aren't going to be supported in the next release of SQL Server.

Speed up SSMS
By on October 17, 2007 No Comments

I saw an interesting post this morning on a blog I monitor. It's about speeding up SQL Server Management Studio for SQL Server 2K5.

Free Training
By on October 15, 2007 No Comments

Every so often Microsoft offers some free training from their e-learning site. At the bottom of this link are some courses listed, some of which still let you register and some of them don't.

SQL Server Performance Tuning
By on October 12, 2007 No Comments

I've recorded a podcast on SQL Server Performance Techniques... 

Time Zone Tool
By on October 11, 2007 No Comments

If you're a DBA that manages systems in multiple timezones, you'll love this handy tray tool that shows up to 5 at a time.

SQL Server Books Online is now Web Searchable
By on October 10, 20072 Comments

Microsoft has created a proof of concept site to see if people like searching Books Online in addition to the traditional table-of-contents approach on the web.

Really cool use of Service Broker
By on October 10, 2007 No Comments

If you haven't learned about the Service Broker in SQL Server 2005, check out this overview.

New Service Model For SQL Server
By on October 10, 20072 Comments

Microsoft has a new model for SQL Server Support.

Rebuilding my test systems
By on October 10, 2007 No Comments

Well, I had some issues that kind of trashed my VMWare installation of my test systems, so I decided it was time to rebuild anyway.

Most larger shops have a "lab" that they use to test things. I normally...

Script out your Report Definition Language (RDL) files
By on October 10, 2007 No Comments

In SQL Server 2005 SP2 (and of course in SQL Server 2008) you can create your own custom reports that will show in SQL Server Management Studio. We’ve seen great adoption of this process, and it can really make Management Studio a one-stop-shop for showing server activity.

Katmai - er, I mean SQL Server 2008 is available
By on October 10, 2007 No Comments

Microsoft announced the release of SQL Server 2008 at TechEd last July, which had previously been called "Katmai". Interestingly, SQL Server releases are named after mountain ranges in Alaska. They've released another Community Technical Preview since then...

And that's why you craft your queries very carefully
By on October 10, 2007 No Comments

The other day I saw a question regarding re-use of query plans. The developer was using "exactly the same" query in two places, but the query plan wasn't being reused - there were a lot of recompiles.

Ouch
By on October 10, 20072 Comments

Sometimes no commentary is really necessary. You hit that key just a little too quickly... 

Free Poster! w00t!
By on October 6, 2007 No Comments

 I post this link from time to time, but it bears repeating.

SQL Server on Vista
By on October 3, 2007 No Comments

If you've been playing around with Vista, you've already hit this problem, but I see it a lot so I thought I'd add it here.

Want to play with SQL Server but don't want to install it?
By on October 1, 2007 No Comments

This is really cool - a pre-built, SQL Server 2005 image running on Virtual Server.

Dogs and Cats, Living together!
By on September 28, 2007 No Comments

Most of the people I spoke with at PASS last week use multiple database systems, most notably SQL Server and Oracle. Although some companies turn things like this into religious war, this isn't always the case.

SQL Server Best Practices
By on September 26, 2007 No Comments

I just finished an article that will be published here soon on the SQL Server Best Practices Analyzer.

Argh! Where is the Service Pack Number?
By on September 24, 2007 No Comments

Don't you wish Microsoft would just use plain language sometimes? Like when you run SELECT @@VERSION to find the service pack number. You get back a cryptic number that you have to scour the web to find. Did you know there's an easier way?

Free Database Class
By on September 21, 2007 No Comments

If you're brand-new to databases and SQL Server, you definitely want to check out the new videos Microsoft has just posted on the Express site.

Should you AutoShrink your databases?
By on September 19, 2007 No Comments

The "AutoShrink" option on a database automatically recovers space in the database - sort of.

Where in the Registry is that?
By on September 17, 2007 No Comments

I've been asked this a number of times - so I thought I'd post the answer here. If you need to find the version number of a particular instance of SQL Server using only the Windows Registry,

Web Applications and SQL Server
By on September 14, 2007 No Comments

I responded to an interesting post this morning on a newsgroup regarding the ISUER account and SQL Server. If you're using SQL Server behind a web applicaiton, you have many options when you connect to a database.

Online Free Labs for SQL Server
By on September 12, 2007 No Comments

You might not be aware that there are several resources that Microsoft provides for free to the public for learning and using Microsoft SQL Server.

Sometimes it's more than the data
By on September 7, 2007 No Comments

I'm very passionate about the database role in technology. As DBA's and Database Developers, we are the backbone of most applications. In some way, some how, most every application stores and retrieves data, so our part of the equation is pretty important.

I want the TaskPad Back!
By on August 27, 2007 No Comments

It's amazing what we get attached to. Blankets, stuffed teddy-bears, and for some of us....

Don't ignore the 101
By on August 21, 2007 No Comments

In my past as a consultant it was always interesting to see the reactions when I would ask certain questions. I'd go out to a site to solve a "huge" or "complicated" problem. I learned fairly quickly not to jump to conclusions, thinking I knew what the problem is from the description I'd been given. Instead, I went down the list. Backups? Maintenance? Logs? All the 101 stuff.

Administrator's Guide to SQL Server 2005

This chapter is from the book
Administrator's Guide to SQL Server 2005

In this chapter, you will examine a targeted approach for data distribution. Using Notification Services, you can trigger specific datagrams to users based on conditions in your database, from notifying someone that a stock price has changed to alerting that a machine has just gone offline.
Chapter 7: Notification Services and the Service Broker - Title Page

In the last chapter, I explained how you can use a feature called Replication to send data from one system to another. That discussion was framed in regard to high availability, but of course you can use Replication for many other applications that require data interchange.

In this chapter, we examine a more targeted approach for data distribution. Using Notification Services, you can trigger specific datagrams to users based on conditions in your database, from notifying someone that a stock price has changed to alerting that a machine has just gone offline. Any type of event that you track in your database is available for use in Notification Services. Unlike Replication, you can use Notification Services to send data to an e-mail address, a cell phone, or using the Simple Messaging Service (SMS) to any device that conforms to that standard.

There are a couple of ways you can use Notification Services. You can treat it primarily as a task that the maintenance database administrator (DBA) is responsible for or you can enable it for your developers. In this chapter, I focus on the DBA side of things, but you should be aware of its many applications.

You can use SQL Server 2005 as part of a robust service-oriented architecture (SOA). An SOA allows you to build applications in a new way, distributing the load across multiple servers using messages between them. SQL Server 2005 provides the Service Broker as a programmable object that you can use as a store-and-forward mechanism. Although you might not write these programs, as the DBA you will be responsible to set up and manage this part of the framework for an SOA.

In the second part of the chapter, I explain how you can help develop and manage an SOA using the Service Broker. I show you a sample application using the Service Broker in the "Take Away" section at the end of the chapter.

In the early days of computing, users did not get immediate responses from their programs. Developers wrote code in either machine language or something close to it, saved it on a media such as magnetic tape or punch cards, and submitted it to a computer. The computer would run the program and create an output, either more punch cards or a printout. The users would receive the printouts as their results, disconnected from the computer. This is called "batch processing"; and most of us could not imagine working this way any more.

In modern applications, users connect to the database either directly or through a data-access layer in the system. They input data and receive immediate feedback using a video screen. This book was produced with a program using that computing method, and you might even be reading it that way.

But there are times when batch processing or disconnected computing is useful. In some applications, the user is not near the computer when the results are tabulated or created but may still need the data. Other systems might also need access to the data but not all at once. The feedback between the data and the user does not have to be immediate.

The value in this paradigm is that you can spread out the system over large areas and balance the loads between the components. Not needing the immediate feedback lowers the amount of resources a system requires.

You are already using at least one disconnected system in your daily routine. E-mail, for instance, is created on one computer at a certain time, stored on another computer at a later time, and picked up and read on still another computer at a later time. The e-mail server provides the reception, storage, and delivery of the message as a service. In effect, e-mail is a part of an SOA. In an SOA, a server provides interfaces and data that are available to any program that knows how to talk to the service. The service can also be coded to accept input, or perform some other action based on the connection.

SOA systems are not new; in fact, Microsoft provides many SOA mechanisms in programs such as BizTalk or as separate add-ons to SQL Server 2000. In Microsoft SQL Server 2005, Microsoft includes the Service Broker directly integrated into the database engine.

If Microsoft already has SOA systems available in other products, why include it in SQL Server 2005? The reason has to do with the requirements that an SOA has. If you are going to allow systems to be disconnected, your SOA has to guarantee that the traffic between the systems is encapsulated into messages so that the sending program is identified, so it can receive the proper answer from the service. You also have to make sure that the messages are ordered properly. For instance, the program might send the third line of a purchase order before it sends the header. The service needs to be aware of the order and the encapsulation so that it can respond to the purchase order only when it is complete, just as in a database transaction.

To manage all this, SOA systems use a database. In other mechanisms, you need to manage not only the SOA system but a complete database as well. By including the SOA within the database engine, the data, metadata, tracking data, and mechanisms are all contained within the same architecture. There is just one system to learn, implement, and manage.

Another type of SOA is a "push"-oriented data system. I explained a little about this type of data movement in the last chapter when we examined SQL Server’s Replication features. In that environment, data is either sent or picked up by another database. Although that is a useful feature, you will often need to send data to a medium other than a database, such as e-mail or an SMS device. In SQL Server 2005, Microsoft includes the Notification Services system that can do just that.

Many people in your technology department are normally involved in creating an SOA, simply because of the vast array of technical skills required to implement and maintain it. As the DBA, you will be asked to manage and maintain the system, working with developers, business analysts, and others.

Notification Services

Notification Services is one of those products that does what it says: It provides a means of notifying a user that an event has occurred in a database. The system uses several components to accomplish this goal, from the databases that store data about the events to the control files and databases that shepherd the process.

Let’s begin by examining a few applications for Notification Services and how you can distribute them. The most obvious uses involve applications that require immediate feedback for a user. These include changes in prices, levels, inventory, and any other information that is time sensitive.

Other uses for Notification Services might not be as obvious. Marketing studies show that clients are most frustrated when they feel that a company is not responsive. You can code your applications to notify a customer as to which stage an order is in, such as when it is complete, when it leaves the building, or any other action that makes a change to a status code in a database. You can also set up a notification that an order was received and when it was placed.

For the system administrator, you can use Notification Services to help reactively manage your systems. Normally, a reactive mode of managing anything in IT is a bad idea, but using Notification Services you can build in the look-ahead logic so that a server watches objects (like backups or other maintenance) for you and can alert you when a threshold is reached.

So just what is Notification Services? It is an infrastructure within SQL Server 2005 that involves a service, instances, and applications, and a set of programs your developers create to interface with the system. In this chapter, I focus on the Notification Services instances and applications.

The easiest way to create the system is programmatically using notification management objects (NMOs). You can find several examples of this type of programming if you installed the sample and applications on your server.

You can also create and manage Notification Services using the native tools within SQL Server 2005 using XML files. We take a look at the structure of these files and examine the results of its implementation so that you can see how to manage and maintain it. In practice, most applications are coded using NMOs, but you can always create the instance and application XML files with an Export from the Object Explorer right-click menu in SQL Server Management Studio.

Notification Services Architecture

There is a lot of excellent information in Books Online regarding Notification Services, but it is not arranged in a holistic view of the system. There is a good reason for that. Notification Services uses several components within the SQL Server 2005 platform to accomplish its goals. In addition to all the capabilities that Microsoft delivers, your developers can extend every part of the system with custom programs and interfaces. To get a picture of how this all fits together, let’s start at the back of the system and work forward to the user who receives the notification.

Because Notification Services has so many components, I am going to cover it three times. In the first, I give you a broad overview, then I explain it again with a little more detail, and then I cover the various basic components by explaining the Instance Configuration File (ICF) and the Application Definition File (ADF). Even with all of this information, you are only seeing a quick overview of this topic.

At the back of the process is SQL Server 2005, which stores the data the users need to see and all of the metadata that Notification Services requires to operate. On top of SQL Server is the NSServer.exe program, which runs all of the instances, which make up the notifications for the users. To create these instances, you have two options: Your developers can create them with programs that use NMOs, or you can create them using an XML document called an ICF.

With an instance created, you create one or more Notification Services applications within it that listen for events, which are changes that your users are interested in knowing about. Events might involve database activities but also can track changes in Analysis Services, files on a file system, and other activities.

These events are matched with subscriptions, which are sent to the subscribers (users) over various protocols to devices such as cell phones or e-mail. Once again, your developers can create Notification Services applications using NMOs or you can create them with an XML document called an ADF detailing the parts of the application.

If you create the instances and applications using XML files, you import them using SQL Server Management Studio or the NSControl.exe command-line program.

That is the first overview, which leaves out quite a bit of detail. Let’s examine the process a bit further. After the instance and applications are created and running, the instance uses a program called NSServer.exe that runs in the background watching for events using an event provider. Event providers watch for database changes, file system changes, and other events. It then applies matching rules to pair up the subscriptions and the events and then sends the data on to a provider. A provider is a piece of software that receives the data and formats it for delivery.

Providers are called by the application, and a generator matches up subscriptions to the events. Subscriptions are groups of data that a subscriber (the user) cares about. Notification Services populates the entire subscription, which is read by a distributor. Distributors use special-delivery services to talk not only to other databases but to file systems, 0e-mail and telephones, and any other kind of communication system your developers create.

The distributor formats the output using a content formatter and then sends it on to the delivery protocol provider, which can send data over SMTP, HTTP, and SMS. The subscriber receives the data in that format, over that protocol.

As the third explanation of the process, let’s take an even deeper look at two of the primary components that you will work with: the ICF and the ADF. Using these XML files, you set up the instances and applications that enable your developers to create a complete Notification Services system. All the pieces I have been talking about begin to come together as you examine these files.

Instances and the Instance Configuration File

An instance of Notification Services is a collection of applications that run as a unit on a SQL Server. You can have one or more instances on a single SQL Server. You can create an instance programmatically using NMOs or by using SQL Server Management Studio and an XML file called an ICF. That is the approach I take here.

The ICF contains the name of the instance, a database for its control, the name of the applications that can talk to the instance, and encryption and delivery information. You can also place a version stamp in the file, which I recommend for production applications. The format for the file is detailed in Books Online under the topic "Instance Configuration File Reference."

I display the minimal ICF file here so that we can talk a little about the parts that are required. In a moment, I show you the results of importing an ICF file into the database using SQL Server Management Studio. If you want a useful example of Notification Services, it is best to consult the examples from Microsoft, if you installed them. Setting up a complete system with an interface and databases and explaining it all would take up much more than a single chapter and would involve you in parts of the system that a DBA does not normally handle. I do recommend you use the examples, however, because they will shortcut all the development for you and allow you to concentrate on managing a Notification Services system.

Here is the minimal version that you need to fill out for a basic instance. Each section is commented out ( <!— comment —>) so that we can more easily discuss it:

<?xml version="1.0" encoding="utf-8"?>
<NotificationServicesinstance 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.microsoft.com/MicrosoftNotificationServices/ConfigurationFileSchema">

<!— Notification Services instance Name —>
<instanceName></instanceName>

<!— Database Engine instance —>
<SqlServerSystem></SqlServerSystem>

<!— Applications —>
<Applications>
 <Application>
 <ApplicationName></ApplicationName>
 <BaseDirectoryPath></BaseDirectoryPath>
 <ApplicationDefinitionFilePath></ApplicationDefinitionFilePath>
 </Application>
</Applications>

<!— Delivery Channels —>
<DeliveryChannels>
 <DeliveryChannel>
 <DeliveryChannelName></DeliveryChannelName>
 <ProtocolName></ProtocolName>
 </DeliveryChannel>
</DeliveryChannels>

</NotificationServicesinstance>

It looks like there is a lot going on here, but it is actually quite easy to follow. The first five lines of the file represent an XML header, which details what the file is and how it will be used. That does not change for any of your instances. The rest of the sections control the creation of the instance, similar to the old .INI files of earlier Windows programs.

<!— Notification Services instance Name —>

The first section, specified in the <instanceName> element, sets the instance name for the system as well as the service it creates to run this instance. From here on out, the applications and other parts of this notification system’s grouping will refer to this name. I usually keep these short and as descriptive as possible. The instance Name becomes the name of the service that runs in the operating system, prefaced by NS$. For example, the following entry creates a service called NS$AWInventory:

<instanceName>AWInventory</instanceName>
<!— Database Engine instance —>

The <SqlServerSystem> element sets the name of the SQL Server instance (no relation to the Notification Services instance set up with this file) where the Notification Services instance will run. It is the name of the server where you want the service to run.

<!— Applications —>

Each instance holds one or more applications that can talk to it. The <Applications> element is a parent element that contains other information that relates to the applications that will run under this instance. In effect, it is pointing to the ADF that you will also need to create prior to importing the instance using the ICF.

This section includes the name of the application and its location and name on the hard drive. You can store these files in a shared folder, as long as the SQL Server and service accounts have access to it.

In this example, I create only one application for the instance, but you can have as many as the resources for your system allows. It is best to plan out the entire system before you begin this process so that the instances are broken out logically to contain the applications that make the most sense to group together.

The first child element in the <Applications> tag is <Application>, which is another parent tag. You repeat this element for each application that the instance will host. Within that parent element is the <ApplicationName> element, which sets the name of that particular application.

Each application needs a directory to store its ADF. This file, which I create in a moment, holds the same kind of information created for the instance but sets up the application.

The next element, <ApplicationDefinitionFilePath>, sets the name of the ADF file. If you store only the filename here, the file needs to be stored directly in the BaseDirectoryPath location.

The reason you have two elements available is because in actual production, you will normally have several applications that run on a single instance. You want to keep these applications separate so that various developers can have the access they need to work with only the applications they are assigned to. Keeping the applications in separate directories allows you a greater level of security.

<!— Delivery Channels —>

The instance controls how the system communicates with the outside world. The first parent element, called <DeliveryChannels>, begins the section describing all the ways that this instance can communicate.

You open the delivery method with the <DeliveryChannel> element, and then type in the <DeliveryChannelName> element to have the type you want, from e-mail to file. Within that instruction, you need to specify the protocol the channel will use. You do that with the value of the <ProtocolName> element.

There are lots of ways to send information, each with its own protocol settings. So that we can maintain the overview process here, I will direct you to Books Online using the topic search I mentioned earlier to learn about the various methods you have available.

With all of the basic elements defined, we need to create the ADF.

Applications and the Application Definition File

One or more applications are contained within a single instance of Notification Services. When you create an application, you will also create or specify a database that stores the events, the subscriptions, notification data, and other application metadata about the application. If you do not have a database, you can have the XML file (or the NMO program) create one for you.

Once again, we will look at a basic XML file and examine the elements it contains:

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://www.microsoft.com/MicrosoftNotificationServices/ApplicationDefinitionFileSchema">

 <!— Version —>
 <!— History —>
 <!— Database Definition —>
 <!— Event Classes —>

 <!— Subscription Classes —>
 <SubscriptionClasses></SubscriptionClasses>

 <!— Notification Classes —>
 <NotificationClasses></NotificationClasses>

 <!— Event Providers —>

 <!— Generator Settings —>
 <Generator>
 <SystemName>%SystemName%</SystemName>
 </Generator>

 <!— Distributor Settings —>
 <Distributors>
 <Distributor>
  <SystemName>%SystemName%</SystemName>
 </Distributor>
 </Distributors>

 <!— Application Execution Settings —>
 <!— Important: At minimum, you should define
 a vacuuming schedule and turn off some or all
 distributor logging. —>

</Application>

This file has quite a few subelements, so once again I recommend that you look up the topic in Books Online using the search topic "Application Definition File Reference." There you will find all of these elements hyperlinked, in alphabetic order. Using this minimal template and those search results, you can quickly build the file you want.

In this minimal file, the first four lines set the header for the XML file and tell SQL Server 2005 how to handle it.

<!— Version —>

The first section here is the <Version> element. Within that are various child elements that set a version number and build. The <Version> element is optional, but I normally include it so that I can track where I am in the build process. It is a good habit to get into.

<!— History —>

The History section is similar to the Version section, in that it provides tracking data for your system. You can include data here to track what changes you have made to the ADF.

<!— Database Definition —>

In the <Database Definition> elements, you set the name, schema, and physical structures for the application. If you do not provide one, the system creates a database using the defaults for the server. In a moment, I create a Notification Services application and show you the types of things that end up in this database.

<!— Event Classes —>

It is in the Event Classes section that things really become interesting. In this section, beginning with the <EventClasses> parent element, you set up one or more <EventClass> elements that define what events the system responds to.

<!— Subscription Classes —>

In the Subscription Classes section, using the parent tag of <SubscriptionClasses>, you set up one or more subscriptions for the application using <SubscriptionClass> elements. Here you describe the name, the schema for the subscription, any indexes you want on the tables, and event and schedule rules. All of these elements set up how often the events are captured and what can be subscribed to.

<!— Notification Classes —>

Using the <NotificationClasses> parent tag in this section, you set up one or more notifications for the application using <NotificationClass> elements. These elements define where your application stores the notifications, what filter is used to format them, and what protocols the transport uses. You can also set whether the notifications are sent one at a time or if they use a "digest," which groups them all together to be sent at the end of a specified period.

All of these settings are similar to what you will see in a newsgroup; and if you think about it that way, you will have the concept.

<!— Event Providers —>

As I explained earlier, an event is a change in data that you care about. For instance, a stock price change or a project change would be an event. Microsoft delivers several of these with SQL Server 2005, and you can also write your own. Here are a few of the event providers that your system can use.

Analysis Services

MDX statements

File Watcher

XML output, requires a schema document

SQL Server

Runs a SQL statement to detect changes; Can be non-Microsoft because it uses linked servers

Custom

Uses IEventProvider and IScheduledEventProvider


The most prevalent event that I have seen used is the SQL Server event. This allows you to watch a table for changes and deliver the information to a user via a subscription.

Each of the event types has specific elements they require to be able to process them.

<!— Generator Settings —>

The generator is the component within Notification Services that matches changes in data (events) to those who should learn about the changes (subscribers). It runs in the background on your server using the NSServer.exe program.

In this section, you use elements to define the name of the system that will act as the generator and set the amount of threads it will use.

<!— Distributor Settings —>

The distributor is the component within Notification Services that formats and sends the data. You can store the distributor on one or more servers to help balance the load on your system. You use elements in this section to set the name of the distributor, the threads it uses, and an optional duration setting.

<!— Application Execution Settings —>

In this section, you set up all of the information around the processing of your events, such as limiting the amount of time that is spent on a particular task as well as the order in which applications are processed. An important element to set is the <Vacuum> value, which sets how often the cleanup process runs.

With all of those components in mind, let’s take a look at how all of it fits together within the framework of a complete application. I have a single application that I plan to set up to watch an inventory level. I have created the ICF and the ADF and placed them in a directory on my local test system. I will import those into my instance of SQL Server 2005.

Installing the Instance and Creating the Application

In Figure 7-1, I have opened SQL Server Management Studio and right-clicked the Notification Services object in the Object Explorer.

Within that panel, I specify the location of the ICF, as shown in Figure 7-2.

With that set, I click the OK button to process the file. My system shows the screen in Figure 7-3 while it processes.

Now I will enable the system by right-clicking it in the Object Explorer again. This process sets the distributors, generators, and subscriptions for the system. You can see that in Figure 7-4.

When that process completes, I right-click the service and select Tasks,... and then Register from the menu that appears, as shown in Figure 7-5.

This brings up a panel where I create the service, set the authorization for the service, and set how the service will access the database. You can see that in Figure 7-6.

I receive feedback that shows that the system is creating registry entries, creating the service, and adding new performance counters. With all that complete, I again right-click the name of the service and select Start from the menu that appears. After confirming that I want the system to start, the databases I specified in the ICF (AWInventoryNSMain) and the ADF (NSMetaData) are created, and the service starts.

Figure 7-7 shows a list of the tables within the instance database called AWInventoryNSMain.

This database contains the elements I explained earlier within the ICF document. There are a few other metadata tables here, especially involving the time settings such as time zone and locales.

The tables in the application database called NSMetaData also contain the elements I explained in the ADF and other metadata. You can see all of that in Figure 7-8.

The service reads these databases and accesses the information, ready for the client programs to subscribe, similar to what I explained for replication.

Security

There are two parts to the security of your Notification Services system. The first is to secure the locations where the ICFs and ADFs are located.

The reason you want these files secure is that those who can access them can change them to reflect more data in the Events section than you might want. The small files I described earlier are not representative of what you create in a production environment. The production files are much larger, so you might miss the addition of a new event or a change to a current one.

After you have your instance running, you can alter it later by re-importing the ICF and ADF. That is where the danger comes in on leaving these areas unsecured. If your developers are using NMOs to code the application rather than the control files, this is less of an issue.

The second part of securing the system is against the subscription data. To secure this data, you simply use Windows accounts or SQL Server accounts.

Monitoring and Performance Tuning

Notification Services can be used on servers that scale up, and they can also be used on a cluster. Another method for tuning the application is to spread it out onto multiple servers, including the generators and other parts of the application. That is why it is important to plan out the system ahead of time.

You can monitor a Notification Services system in SQL Server Management Studio by right-clicking the instance you are interested in and selecting the Properties item. Once inside, click the Applications item in the left pane, and in the Components for that application, check the Status column, as shown in Figure 7-9.

You can also check the Subscriber status from this resource box. Another monitoring tool is a suite of Performance Monitor objects and counters that you can access from the System Monitor in Windows, as you can see in Figure 7-10.

You can monitor all parts of the system based on what you are interested in examining, from the subscriber subsystem to the collection methods.

  • Share ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

There are currently no related podcasts. Please check back later.

Great password information at a small price
By John Traenkenschuh on June 13, 2009 No Comments

Where can cash-strapped security pro's get great information on security basics??

Steven HainesOracle Buys Sun of $7.4B
By Steven Haines on April 20, 2009 No Comments

In a stunning turn of events, Oracle steps in and buys Sun amist the breakdown of IBM's attempt to acquire Sun.

Buck WoodyIf it's Free it's for Me
By Buck Woody on January 26, 2009 No Comments

Sign me up for anything free these days. I just ran across a book that promises to help you build a web site for free...

See All Related Blogs

Informit Network