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

SB floods with query notifications

$
0
0

I'm working on a super simple C# SQLDependency app which seems to work fine on a test DB I created with a very simple implementation. I enable Service Broker on the DB, and register a few queries with the C# SQLDependency class.. here's some pseudo-code:

void Start(){
    SqlDependency.Start(connectionString);
}

void SetupDependency(){
    SqlCommand currentCommand = new SqlCommand("SELECT AccountId FROM dbo.Accounts WHERE AccountId=123", this.CurrentConnection);
    SqlDependency dependency = new SqlDependency(currentCommand);
    dependency.OnChange += this.dependency_OnChange;
    currentCommand.ExecuteNonQuery();
}


void dependency_OnChange(object sender, SqlNotificationEventArgs e)
{
    SqlDependency dependency = sender as SqlDependency;

    dependency.OnChange -= new OnChangeEventHandler(dependency_OnChange);
    // do some things with the event, re-register the dependency again etc.
}


In my test DB this all works fine. When I update the record, I get the notification.

However, in my production DEV database as soon as I connect and register dependencies I receive back a constant stream (thousands) of Query notifications on that single record. The SqlNotificationEventArgs reveal:

SqlNotification.Info = Query
SqlNotification.Source = Statement
SqlNotification.Type = Subscribe

I don't seem to receive any other types of notifications, such as when updating the data (SqlNotification:: Info.Update Source.Data Type.Change type events), I only get these Query events. I've checked the SB Queue that gets automatically created when I do a SqlDependency.Start(), and it's filling up with thousands of these notifications. The message body is:

<qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotification" id="0" type="subscribe" source="statement" info="query" database_id="0" sid="0xFA3808D148F75649A905EB8EE9C02842"><qn:Message>84208d96-67fc-4847-b80c-18afa2bd0c81;683d992f-45ad-4701-9032-6316ecb8716b</qn:Message></qn:QueryNotification>

Does anybody have any idea where these could be coming from? And why I don't see them on my test database? There may be a small amount of read activity on my DEV database, but I confirmed there were no updates running and certainly not thousands of reads on a single record. I'm stumped!

Thanks!


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>