Quantcast
Channel: SQL Service Broker forum
Viewing all articles
Browse latest Browse all 461

SQLDependency (C#) w/custom queue name isn't working

$
0
0

Hello all,

I've written an application that uses the .Net SQLDependency class as directed in the docs. It works fine when I let the default behavior create the SB service/queue automatically as follows:

SqlDependency.Start(connectionString);

However when I give it a queue name in the constructor it doesn't receive any events:

SqlDependency.Start(connectionString, "SBQueueService");

I don't want SqlDependency to create the queue for me each time, as during development I end up with dozens of services/queues registered all with a default max queue readers of 1. My service broker SQL is:

ALTER PROCEDURE [dbo].[SBQueryProc] AS 
BEGIN 
	BEGIN TRANSACTION; 
	RECEIVE TOP(0) conversation_handle FROM [SBQueueService]; 
	COMMIT TRANSACTION; 
END;

CREATE QUEUE [dbo].[SBQueueService] WITH STATUS = ON , RETENTION = ON , ACTIVATION (  
STATUS = ON , PROCEDURE_NAME = [dbo].[SBQueryProc] , MAX_QUEUE_READERS = 16 , EXECUTE AS OWNER  ) ON [PRIMARY] 

CREATE SERVICE [SBQueueService] AUTHORIZATION sb ON QUEUE [dbo].[SBQueueService] ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]);
IF (SELECT COUNT(*) FROM sys.database_principals WHERE name='sql_dependency_subscriber' AND type='R') <> 0 
BEGIN 
	GRANT SEND ON SERVICE::[SBQueueService] TO sql_dependency_subscriber; 
END;  

Does anyone see any issue with how it's being setup? I've captured the SQL that the SqlDependency class sends and I seem to be doing the same thing, but I don't receive notification events.


Michael Brown, 360 Replays Ltd. (don't forget that 'Mark As Answer' button!)



Viewing all articles
Browse latest Browse all 461

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>