We have implemented sqlcachedependency in our application. We have multiple caches depending on one database table and set the sql cache policy with a sql monitor as shown below.
policy = new CacheItemPolicy();
//connection string name
var connectionString = connectionstring;
//SQlDependency Cache
SqlDependency.Start(connectionString);
SqlChangeMonitor monitor = null;
using (var connection = new SqlConnection(connectionString))
{
using (var command = new SqlCommand("SELECT col1,col2 FROM dbo.table1", connection))
{
var dependency = new SqlDependency(command);
connection.Open();
command.ExecuteReader();
monitor = new SqlChangeMonitor(dependency);
}
}
policy.ChangeMonitors.Add(CreateMonitor());
This method is called while adding multiple cache. Everything is working fine when we check on the development machine. But once we upload the application in load balanced QA machine(QA1,QA2,QA3) it is not working.
All the grant permissions and sql broker enabling is done on the database.
When we check the sql profiler, we see that subscriptions are being registered in the database. But the notification from the sql broker and not working back in the application when an update is done on the table. We see the following error in profiler
**Cannot find the remote service 'SqlQueryNotificationService- ab49a23a-9beb-4a6f-a8b0-299bcfddbeda' because it does not exist. and
This message has been dropped because the TO service could not be found. Service name: "SqlQueryNotificationService-58237ce1- aa4d-4999-9fd8-d0b78c1d932b". Message origin: "Local".**
Any help regarding this will be highly appreciable.