-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load balanced environment and use of END CONVERSATION causes issue #29
Comments
In our case we implemented GoF observer (design) pattern in lieu of http://www.dofactory.com/net/observer-design-pattern On Tue, Aug 23, 2016 at 1:10 PM, smillerk2 [email protected] wrote:
|
Thanks for the quick response - much appreciated. So if I understand correctly, you're saying that if Server 1 calls
Server 2 will still pick up the notification and call the same END CONVERSATION? Is there anyway to verify if that is happening easily as it doesn't look like this is occurring for me? |
You make no changes to SqlDependencyEx software implementing 'observer' I made an assumption that could be wrong about your implementation of The registered listener of table change events is the 'subject' in an I included the link not with the intent you purchase software, but had in cf On Tue, Aug 23, 2016 at 1:38 PM, smillerk2 [email protected] wrote:
|
Hi @smillerk2, As far as I understood you have a database and many clients which listen to the same table. It might not be a good idea to use the component as a basis for a client-server application, but if you want to get notifications simultaneously on many clients you should create a SqlDependencyEx instanse for each client with different identities. It is not recommended though. By creating an instanse of the component you create a DML trigger and a notification queue which might cause performance problems if there are many clients. The best practice here would be to have a single super client which receives every event from the db and many minor clients which receive notifications from the super client instead of the database. Let me know if there is a misunderstanding or you have other questions. Thanks, |
Hi Dmitrii, That is very helpful. I "only" have 2 clients (web servers in a cluster) and they both need to listen to specific tables as you have described. There are about 20~ tables of interest that currently do have a DML trigger and their own notification queue so if I opt for unique identities then this will obviously double in size. Although not optimal, this might be less work than refactoring to use a super client as I know I will never have more than 2 clients. So, I think my SQL 2014 with 64Gb RAM should be able to handle 40-50~ queues on a database. Do you agree? Great library by the way. |
Hi @smillerk2, It might not be possible to implement. As far as I remember there is a converstation queue which is basically a table of some kind and a special SQL server instruction - WAITFOR RECEIVE TOP which hangs the thread from which it has been called until there is a message (aka a row) appeared in the conversation queue. That instruction will relase the calling thread every time when something is in the conversation queue. If you don't delete a conversation message from the queue when you receive it in C# - you will receive the same message again in the next loop cycle. Here is the question: WHO should cleanup the conversation queue? If you have two clients which of them should clean it up? How can a client be sure that other clients have already received the message and confidently remove it? Thanks, |
Hi Dmitriy - I'm not sure who this comment is directed to, I apologize if If directed to me, and the context of discussion is implementation of We have used this pattern in in production capacity, at a large Fortune 2 I am all to happy to discuss technical details, please let me know. Curtis On Wed, Aug 24, 2016 at 9:38 PM, Dmitriy Dyatchenko <
|
Hi Curtis, Sorry for the churn, but the comment was addressed to @smillerk2 as an answer on his last question. Thanks, |
Thanks Curtis and Dmitrii for the discussion. So, summarizing, we can say that my original idea of not ending the conversation is an extremely bad one because of what Dmitrii says in his last post around who ends the conversation and if it's not ended it would simply remain on the queue. But in an earlier comment from Dmitrii he did say that using multiple unique identities would work as this would result in multiple triggers being created per table, each with their own queue, but it just wouldn't scale very well. |
Hi @smillerk2, Yes, the solution with different identities would work but it might cause performace problems. Hovewer, if you have two clients only and you are not going to increase this number - that might not be a big problem. You can try it at least and see how it goes. But the observer solution is definitely better. Thanks, |
Hi I am coming to this thread after one year it was closed. Not sure anyone still can help me. I downloaded this and I can see the table is being watched. I am trying to make it work for multiple listeners. There is a mention about some links for samples, may I know is there any sample example exist for multiple listeners Please advice. I would appreciate if some one can get back asap? Many Thanks |
Sorry I mean examples with Observer being implemented. Can some one post the solution or point me in the right direction if any such samples exist. Thanks |
Also is it possible to set for example notify observer1 only for certain criteria, like AccountId <= 25000 |
I think what you want is an Actor model like Akka.net or maybe Command Dispatcher like say BrighterCommand. Those are really going to give you a lot of power and handle message distribution. I would really recommend not extending the SqlDependencyEx library to do all these things, instead compose your applications from testable and separable components. In this case have a single table listener that then dispatches actor messages or commands and the let that take over all the details about message delivery and handling it is much better at that and designed for it. |
Hi Dmitrii,
If I have more than 1 server listening for the event notification, I am finding that the first server "wins" and other servers do not receive the notification event.
Is this because of:
Should that line be removed so that all servers receive the message or is there a setting I am missing?
The text was updated successfully, but these errors were encountered: