sqldependency

How efficient SqlDependency (Service Broker) is compared to query by timer?

时间秒杀一切 提交于 2020-01-02 10:04:06
问题 I need to notify users (around 100 clients) of my software (C#, .NET 3.5) when there are new records added in one of the tables of my database (SQL Server 2008). If I understand it right, such operation should qualify as cache invalidation which is exactly what is SqlDependency for, please correct me on this one if I'm wrong. For that I can see 2 options: SqlDependency which will allow me to receive practically realtime notifications. Checking table by some timer. But I never used

How to figure out which SQLDependency triggered change function?

冷暖自知 提交于 2020-01-01 17:26:08
问题 I'm exploring query notifications with the SQLDependency class. Building a simple working example is easy, but I feel like I'm missing something. Once I step past a simple one-table/one-dependency example I'm left wondering how can I figure out which dependency triggered my callback? I'm having a bit of trouble explaining, so I included the simple example below. When AChange() is called I cannot look at the sql inside the dependency, and i don't have a reference to the associated cache object

Cannot find the object “QueryNotificationErrorsQueue” because it does not exist or you do not have permissions

坚强是说给别人听的谎言 提交于 2019-12-28 06:55:28
问题 I am using SqlDependecy with signalR to push notifications to client browser when there is some database changes, I followed this and this post and everything works fine in local SqlExpress version 11.0 with Local Connection String , but i have some kind of permissions problem when i connect to remote database hosted in GoDaddy with Production Connection String Working Local ConnectionString <!--<add name="NotifyConnection" providerName="System.Data.SqlClient" connectionString= "Data Source=.

Using SqlDepedency OnChange event with SignalR adds new global event on each refresh and each time new client connects

大兔子大兔子 提交于 2019-12-25 16:38:31
问题 Usually I manage to solve a problem by reading posts here, but this time I can't seem to find the specific answer to my problem. I've been trying SignalR for pushing database changes to each client connected using SqlDependency - this didn't take me long to accomplish. The problem is that each tutorial is giving the exact same examples on how to push notifications to the users/clients, but I can't seem to get it to work. My code looks like this: Startup I initialize the following line when my

Ensure SqlDependency was Stopped

不打扰是莪最后的温柔 提交于 2019-12-25 08:57:41
问题 SqlDependency starts on application start and stops on app stop. There are can be cases when SqlDependency.Stop() failed (for example, problem with connect to DB). As I understand, the SqlDependency infrastructure will be removed anyway by timeout. But I don't understand what else SqlDependency.Stop() do? Does it make sense to call SqlDependency.Stop() before SqlDependency.Start()? 回答1: Does it make sense to call SqlDependency.Stop() before SqlDependency.Start()? If Start() was not called,

Use of SqlDependency blocks executing method

大憨熊 提交于 2019-12-25 02:53:07
问题 I am experimenting with SqlDependency at the moment. I have a watching console application that really does not do anything than creating the SqlDependency object on a defined SqlCommand and then call dependency.Start(); The statement to be watched contains 2 inner joins. To test this now, I wrote another console app that updates a record that should change the result of the defined query. The data in these tables is about 1 million rows / table. Now when calling the method that executes the

Filtering Data Table inside Hub Class PREVENTS SQL Dependency to run

旧城冷巷雨未停 提交于 2019-12-24 21:18:39
问题 I am using SignalR and SQL dependency to deliver real time data based on a SQL Server query with parameter related to the user connectionId. I have a strange problem related to SQL depedency: I am sending a userid through query string to the hub. For each hub start, I am saving the connection Id and that userId in SQL Server database and my SQL query which I am linking to SQL dependency has filter related to the connectionId. I tried to include the filter based on that connectionId in the

SignalR & SqlDependency Query performance

Deadly 提交于 2019-12-24 11:37:30
问题 I have a Table, it has around 1 million rows. This table is updated by web services, CMS applications and other sources. I want to Monitor few columns within this table. I read about SignalR and SqlDependency . However it seems like SqlDependency will re-scan the entire table on every change ?? My table is pretty large and I cant afford to rescan the DB upon every change. is the only solution is to use Trigger or something? I really want to stay away from Triggers. Here is the code: public

SqlDependency in asp.net

拟墨画扇 提交于 2019-12-24 03:58:31
问题 I'm using SqlDependency to control my cache. I want to use it to monitor several tables (around 10). There should be one SqlDependency per watched table. Should I create for each of them code like that: public void CreateDependency_Table() { if (connectionStringSettings != null) { using (SqlConnection conn = new SqlConnection(connectionStringSettings.ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("SELECT id from dbo.Table", conn)) { cmd.Notification = null;

SQL Query Notifications do not always work in scaleout setup (SQL Server)

一个人想着一个人 提交于 2019-12-24 01:18:44
问题 SQL Query Notifications do not always work in our environment. They seem to work for a little while, and then we get an ArgumentException (Invalid token for impersonation - it cannot be duplicated) exception on SqlDependency.Start(...) method call, and SqlMessageBus falls back to using polling mechanism. After that, SQL Query Notifications are not attempted until the SQL message bus has been disposed. It seems that, SqlMessageBus doesn't always see that SqlDependency has already been started