sql server notification services:
Hi everybody,
could You please give a suggestion whether Notification services (NS) should
be used in following situation ?
We have two SQL Server databases (lets call it A and B) on the same SQL
server instance. 'A' database contain common data that could be reused
across various applications. 'B' database is dedicated to particular
application.
There is a USER table located on 'A' which is also replicated to database
'B' (but not backwards!). We also have some USER_EXT table that references
table USER on 'B'. But there is no 'USER_EXT' table on 'A', because this
table contains project specific data.
Some of our business component (we use COM+) is intended to manage user
data. In order to insert a new user, it should insert a record into USER on
'A', then wait until its replicated to 'B' and only then insert project
specific data into USER_EXT (because, as mentioned earlier, this table
references USER by foreign key).
The problem is that business component must not insert into 'B' until data
from 'A' is replicated into 'B. We don't want our business component to
query database 'B' until data is replicated because it would create
additional database load. We have never used NS before and thought that
maybe it would suit our needs to inform business component when data is
replicated.
I have read some NS books online and studied Stock sample. The first
impression is that NS is not intended to be used in situation like this. At
least event providers and notificaton generators of sample applications are
supposed to run in specified time intervals (e.g 30 seconds). But would it
be efficient to run NS when this interval is short enough - in our case it
shouldn't be longer than few seconds.
Another issue is that notification are supposed to be delivered to some
'devices'. In our case there is no devices, but of
So, the question - would You use NS is situation mentioned above or maybe
You have some better suggestion ?
If You would, then does the following solution looks OK for You:
- there would be a trigger created on 'USER' on 'B' that fires on insert of
new record;
- trigger executes something like (example taken from 'Stored procedure
ference')
DECLARE @BatchID bigint
EXEC NSEventBeginBatchStockEvents N'StockEP', @BatchID OUTPUT
EXEC NSEventWriteStockEvents
@EventBatchId=@BatchID,
@StockSymbol=N'AWKS',
@StockPrice=68.14
EXEC NSEventFlushBatchStockEvents @BatchID
and inserts events into event table of NS application.
- custom delivery protocol would deliver notification to some Remoting
object;
- business components (COM+) would be able to access Remoting object (maybe
subscribe to its events or smth. like that) and get notification when data
is replicated from 'A' to 'B'.
It would be nice to hear if You have better ideas.
Thank You for Your time and suggestions!
Linas
programmer