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

SqlDependency only generates OnChange events with Type = Change, Source = Timeout and Info = Unknown when using the 3-parameter constructor

$
0
0

I'm running a .net 4.6.1 application against a Microsoft SQL Server Standard Edition (64-bit) 10.50.1600 RTM, where I use SqlDependency on simple queries (SELECT Column1, Column2, Column3 FROM [dbo].Table WHERE Active] = 1).

I'm using my own Queue and Service:

CREATE QUEUE MyQueue

CREATE SERVICE MyService ON QUEUE MyQueue ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification])

After that, I start the SQLDependency:

SqlDependency.Stop(Configuration.ConnectionString, "MyQueue");
SqlDependency.Start(Configuration.ConnectionString, "MyQueue");

Once that is done, I run all of the queries that I want to watch:

// Create Command...
SqlCommand command = new SqlCommand("SELECT Column1 FROM [dbo].Table WHERE Active = 1", _connection);

// Create SqlDependency...
SqlDependency dependency = new SqlDependency(command, "service=MyService", 60);
dependency.OnChange += onDependencyChange;

// Run the query (this will activate the SqlDependency)
// and pass the results to the onChange delegate
using (SqlDataReader reader = command.ExecuteReader())
{
  ProcessReader(reader);
}

But instead of being notified whenever something changes in that table, I only receive Change/Client/Error or Change/Timeout/Error notifications.

If I use the 1-parameter SqlDependency consturctor (thereby using the default service/queue), all seems to be working correctly. =

I did not notice this behavior on my Dev system, but it does show on multiple test systems. Could the SQLServer configuration have something to do with this?




Viewing all articles
Browse latest Browse all 461

Trending Articles



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