Last post Nov 24, 2014 02:19 PM by SantyM
Nov 06, 2014 11:48 AM|SantyM|LINK
I am using signalR in my application. Here is my use case
the data which needs to broadcast is generated by multiples threads. A single client can fall in multiple groups.
A thread can broadcast to mulitple groups. What will happen if more than one thread broadcasting at same time to a groups.
Do I have to take care of synchronisation while broadcasting the messages or is this taken care by SignalR ?
Nov 07, 2014 04:13 AM|Kevin Shen - MSFT|LINK
Based on my understanding，it will taken care by signalR.
since multiple threads will be running the same instance of your hub code, the class has to be threadsafe.
I suggest that you can refer to the link below:
Nov 07, 2014 09:58 AM|SantyM|LINK
Thank you for reply , from above example it looks like we have to handle the thread synchronisation. My application will be an enterprise level application and if all threads are waiting to write on message bus it will hamper the performance. Please advise.
Nov 10, 2014 01:54 PM|SantyM|LINK
Nov 12, 2014 09:22 PM|mariozs|LINK
You can try to use to async method in signalR
Nov 14, 2014 01:14 PM|SantyM|LINK
I am aware of async methods, but I dont think they are related with my scenarios ,
My question is about synchronisation between the threads who are writing to client message bus at same time. Do we have to take care of it, that is only one thread can write the base at a time or is this something which SignalR takes care internally ?
Let me elaborate it more, 4 threads are running parrallely and taking data from different data sources. There will be no static instance sharing between the threads as they are connecting to different data sources, there will be high frequency updates from
each data source and one client can be subscribed to multiple data sources i.e. it can belong to mulitple groups as I created group for each data source. How can I handle this kind of scenario ? How can I avoid race condition for writing to client message
Nov 21, 2014 11:15 AM|SantyM|LINK
I am waiting for answer. Please reply
Nov 21, 2014 06:53 PM|ben_a_adams|LINK
The broadcast safety should be handled for you. The synchronisation in the example is for the server-side store of the stock prices, not the broadcast.
Nov 24, 2014 02:19 PM|SantyM|LINK
I checked above stock tickre example and the method BroadcastStockPrice
() which is broadcasting to message bus is called in thread safe manner.