简体   繁体   中英

Service Fabric Actors and SignalR

I'm hoping someone can point me in the right direction. I see a chat example for Actors at https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-actors-pattern-distributed-networks-and-graphs/#smart-cache-code-sample-groupchat but that example only shows part of the chat story. Chat's a good example for me because it's similar to the problem I'm trying to solve.

For my problem, clients that push messages into the Actor network also need to receive updates when the state of that network changes. I believe the obvious tool for this is SignalR, but I'm kind of stuck at that point. The Actor SDK doesn't seem to provide a reliable way of streaming state changes out of an Actor. And from what I read, Actor Events don't seem to be reliable enough for this scenario (I'm guessing that's the case, since the documentation says "best effort").

So take the chat example on the SF site. Where do I go from there? How do I subscribe to Actor updates from an ASP.NET Signalr Hub?

The best answer that I've come up with so far is to move pub/sub stuff out of Service Fabric Actors and over to another tool. For example, for my particular problem, I use Redis's pub/sub feature.

Typically you want a 1-to-1 relationship between client and actor or 1-to-many relationship between client to actor. With that being said I would design it so that the client sends messages to the actor, and the actor is responsible for ensuring the message is delivered to the "session" (via reminder). The session I view as a stateful service via reliable collection for that "session". As updates reach the session they call the hub method to broadcast the changes to the appropriate clients.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM