问题
In our service fabric application we have a service that requires keeping some data in memory during operation to optimise performance, however in some rare cases we need to clear this data.
So at some point, a call comes to this service and tells it to empty its cache. The problem arises that we may have several instances of this service, and when you call a service (from another service) in service fabric the call only ends up going to one instance. I need a to call all instances of this service.
We connect to our services (using a generic method) like so:
T service = ServiceProxy.Create<T>(serviceUri);
Is there a way to specify an instance of the service to use? Or some other way to get a message to all instances of a service?
Thanks
回答1:
This seems like a perfect use case for Service Fabric Pub/Sub. Just have all the services that need to clear their in data memory be subscribers, and then your calling service can publish the message which will broadcast to all subscribing services.
See more here: https://github.com/loekd/ServiceFabric.PubSubActors.
来源:https://stackoverflow.com/questions/40532285/call-a-specific-instance-of-a-service-in-azure-service-fabric