How to notify for a db update from Wcf service RRS feed

  • Question

  • Dear all,

    I am designing a service oriented architecture in which different client use endpoints to update different database table and handle request.

    In some situation when a databse has been updated, I need to informed other client application about that new change in order they refresh their data.

    Ideally would be the existance of a kind of notification service that client subscirbe and then gets informed when data they are interested in gets updated .

    But what is the easy way to implement such notification for client app ?

    Any advise or sample will help


    Wednesday, September 5, 2018 7:29 AM

All replies

  • hello,

    In fact you can use the ServiceBroker SQL Service, for such feature I'm using SqlTableDependency which activate de ServiceBroker Service and notify based on a certain operation type that you can set, for example  : (SqlTableDependency project Github)

        public class ServiceBroker<TEntity>
            where TEntity : class, new()
            public event Action<TEntity> OnTableChangedCallBack;
            ITableDependency<TEntity> _tableDependency;
            string _connectionString, _tableName, _queueName;
            public ServiceBroker(string tableName, string queueName, string connectionString)
                _tableName = tableName;
                _queueName = queueName;
                _connectionString = connectionString;
                _tableDependency = new SqlTableDependency<TEntity>(connectionString, tableName);
                _tableDependency.OnChanged += _tableDependency_OnChanged;
            public event Action<TRecordChangedEventArgs<Entity>> OnTablesChangedCallBack;
            private void _tableDependency_OnChanged(object sender, RecordChangedEventArgs<TEntity> evt)
            public void StartTrackingChanges()
            public void StopTrackingChanges()

    you can use this class as an example for a generic service that use the SqlTableDependency to subscribe to table changes.

    Good Coding;

    Wednesday, September 5, 2018 11:20 AM
  • Thnaks but how to you nuse this servce broker from client application ?

    Actually my client application is WPF desktop app thta need to be notify on a table change in order to force a re read of data to be in sync

    thanks for help

    Wednesday, September 5, 2018 11:24 AM
  • Welcome, 

    I guess it will be more architectural solution than something else, for example you can develop a wcf service that broadcast the event when captured by the TableDependency, it should be a duplex service, here is an example on code project, I'll try to add a code example to the code gallery.

    Good Coding;

    Wednesday, September 5, 2018 11:31 AM