Hi,
The Server: SQL Server 2005 Enterprice
The Problem: When using Service Broker & sqlDependancy & QueryNotification I have a problem with several quick Insert statemens into a Table on SQL server which cannot be properly "notified" to the client App. One sql query - several INSERT statements.
Scenario:
1. A table "Signal" is used to keep track on every signal arrived(Inserted) in the system.
2. There is an winApp which on every async signal perfoms a regular INSERT INTO dbo.Signal ... and it's workin' well.
3. There is Another winApp which based on SQL Notification visualize every new(INSERT) and this winApp is working well.
==== So ... everithing is lookin' perfect but ....
4. There is a need on a timely bases (10 mins or ... 2 hours/etc) to perform Bussiness routine and based on it to perform multiple INSERT statemants into this SIGNAL table.
5. I developed 2 possible approaches:
5.1 SQL Job defined on an appropriate schedule to execute an SQL stored Proc with a sql server cursor with multiple INSERT statements. (OR ... INSERT INTO SELECT Multiple Rows which the system need)
5.2 WinApp which executes on a timer bases and perform the same routine. Get Multiple Recordset and forEvery Record make an INSERT into Signal
(THE NEWLY BATCH INSERTED RECORDS MAY BE 10~1000)
THE CONCLUSION: In both approaches a query with multiple inserts or a clientApp with cycle on records notifies the client App only once. BUT:
6.1: If I use WAITFOR clause in the cursor after each INSERT in SQL Job Approach for more than 3 SECONDS I received my records in the client Monitor App
6.2 The same result in the winApp if I a"sleep" the workin' thread for 3 secons.
So ... I'll appreciate every advice for this UNEXPECTED behaviour of the SQL Broker with SQL Notification & what is the proper timing of that technology to work PERFECTLY WELL :) ... or what am I missing?
Thanks In Advice
PS: The client winApps are developed with c#. I tried to perform Bussiness routine for Multiple Insert with a single and multiple sql connections. The same result. The SQL Server cannot respond (Notify) adequat on a single query with multiple INSERT statements.