all groups > sql server notification services > march 2007 >
You're in the

sql server notification services

group:

Suggested configuration?


Suggested configuration? Andy
3/27/2007 1:50:57 PM
sql server notification services: Hi,

I need to build a notification system that will send notifications
when a certain field changes in my database. Other data for the row
may change, and that should not cause a notification to be sent. I'd
also prefer not to create a column just to track when the field i'm
interested in changes.

My first though was to use chronicles and to schedule a subscription
(I only want one notification sent to subscribers a day). Attempting
this has been rather challenging.

Now I'm considering having immediate notifications and events, and
simply using a hosted provider that only runs once a day and compares
the last view to the current value for all rows whose ModifiedDate is
greater than the last time the provider ran.

I think this will be quite a bit simpler, but I want to make sure I'm
not violating any basic principles behind NS application design.

Thoughts?
Thanks
Andy
Re: Suggested configuration? Ken
3/27/2007 5:10:17 PM
Do you have Shyam Pather's book 'Microsoft SQL Server 2005 Notification
Services'?

It has great example projects and source code, etc that demonstrate
different NS principles.

Your problem looks similar to the Subscription by Genre functionality in his
Music Store sample. As songs get added to the Music Store inventory, they
generate distinct events, but the Subscription by Genre rule only generates
one notification per day.

So if you threw a update trigger on your table, you could insert events into
an event view whenever your special field changes, and then have a scheduled
subscription that fires off a single notification per day no matter how many
times the field changed.

[quoted text, click to view]

Re: Suggested configuration? Andy
3/28/2007 7:23:33 AM
[quoted text, click to view]

Ken,

Yes, I have read that book. The problem with your suggestion is that
if the field is changed back later that day, no notification should be
sent at all for that row, but the trigger would cause two
notifications. The resulting notification would be confusing, because
it would instruct the subscriber to add and remove the same person..

That is the reason I was thinking of putting more logic into the event
provider; the only time the events should occur is at the end of the
day, not throughout the day.

Andy
Re: Suggested configuration? Andy
3/28/2007 8:55:57 AM
[quoted text, click to view]

Hmm, I hadn't thought of that. Although it seems more complicated
then just running the SqlProvider once a day.
Re: Suggested configuration? Andy
3/28/2007 8:56:47 AM
[quoted text, click to view]

Before I decide how to proceed, is there a reason that I shouldn't
just go with the plan I suggested? Does it violate some basic NS
principle that will cause me problems down the road?
Re: Suggested configuration? Ken
3/28/2007 11:01:21 AM
[quoted text, click to view]

What if the event stored the value of the field at the time of the event,
and the trigger did something like:

If there is an event the same day with a different field value
delete the event
else
insert an event

then do the notifications once per day


Re: Suggested configuration? Joe Webb
3/28/2007 2:16:36 PM
[quoted text, click to view]

Given what you need to accomplish, I'd say your plan would work. However,
I typically try to not pin my solutions to what the specifications du jour
are.

In your case, making design decisions that limit the number of times
throughout the day that the event provider can run may cause problems down
the road when/if someone changes the requirements. So, I'd lean towards a
chron table with insert/delete logic as Ken suggested.

Just my thoughts, FWIW...

Cheers!

--
Joe Webb
SQL Server MVP
http://www.sqlns.com



Re: Suggested configuration? Ken
3/28/2007 3:02:10 PM
[quoted text, click to view]

Well I am certainly not an NS expert, so I can't speak with authority about
your solution, which seems fine to me....

AddThis Social Bookmark Button