3
votes

Can you create a Hub that you can send messages to clients from worker roles and web roles, or have multiple different worker roles that can sent messages to clients?

Or is the recommend way to sent message to clients with SignalR to have a web role that handles all the messaging to the clients and you would use a queue to send messages from all the other roles to the clients. The other option that I see that I would have a hub for all each worker role and web role and you connect to a few different hubs? this seems like a bad approach to me.

The end goal for our hosted service is to have at least 2 web roles and 3-5 worker roles and the system is very event driven and would like to push messages to web clients when they happen, and not add another stage in the event pipeline for sending messages to connected clients.

1
I found the answer to this: you can do it. If you create a ServiceBusScaleoutConfiguration and <pre>GlobalHost.DependencyResolver.UseServiceBus(serviceBusConfiguration);lockwobr
I found the answer to this: you can do it. If you create a ServiceBusScaleoutConfiguration and GlobalHost.DependencyResolver.UseServiceBus(serviceBusConfiguration); You can use the IHubContext as you would in a webrole and it will work in worker role.lockwobr
I understand you are sending signalr messages from the worker role to the backplane and the web roles broadcast the message to connected clients? Can you elaborate how you did that? Do you need the hub class itself to be accessible in the worker role? Do you do something special to set things up? (best if you can answer your own question). Thanksdaramasala

1 Answers

2
votes

You can have your Azure worker roles make requests to your web roles via Ajax or the SignalR .NET client. You can then have your web roles proxy the messages sent from your worker roles to your "normal" (presumably JS) clients. You can use groups or a special worker role Hub to distinguish between your worker role clients and normal clients.

If you want to proxy messages from your worker roles as part of an Ajax response, you probably want to look at using GetHubContext so you can broadcast to clients from outside a hub.