Showing posts with label fired. Show all posts
Showing posts with label fired. Show all posts

Sunday, March 11, 2012

Can Events be fired in a certain order?

I am getting my arms around Notification Services (NS). We need to generate notifications based on about 5 different subscriptions. The 5 events that feed the subscriptions will be SQL based and will read from a work table. I would like to populate that work table with a subset of our high volume transaction data, run the events, and then clear the data for the next run...say 5 minutes later. So my question is, how do I know when the last of the 5 events has fired so I can clean out the data. In other words, I'd like the 5 events to fire in a certain order and have the last event clean up. Is there a way to tell the events in what order they can fire? Or other suggestions on how to solve this? I read up on Chronicles but it wasn't clear to me if that would solve my problem.

Secondly, if my events and subscriptions created notifications for 5 different subscriptions, can they be combined into one e-mail to be delivered to the subscriber? In other words, there are several subscription events that may happen during the day for a subscriber. The subscriber only wants one e-mail at the end of the day. Will NS combine it?


There are several ways to recognize new events in the SQL Server Event Provider. A couple that I've used in the past is:

1) Use a postprocessing query to update a column in the data source indicating that the row has been processed.

2) Use a Chronicles table to track the datetime of the last query and only look for rows that have been added since then.

HTH...

Joe|||Thanks Joe. That does help.

Friday, February 24, 2012

Can activation SP wake up a thread?

Newbie question, but is there a way for me to set up a thread in my c# code so as it sleeps until it gets woken up by an event fired by an activation SP?

As in queue sits idle, thread sleeps.
Queue receives a message, activation SP gets fired, activation SP raises an event which gets caught by event handler in code, which wakes up thread to do processing?

The activated procedure can be C# code (an assembly in the database). Once activated, your CLR code would be invoked in a thread inside SQL Server and can issue a RECEIVE (using SqlCommand) to retrive the messages from the queue.

If you want your C# code to be in an external application (an .EXE) then you should use external activation instead of internal activation. Have a look at the External Activator sample at http://www.codeplex.com/SQLSrvSrvcBrkr/