在Azure Service Fabric中调用服务的特定实例 [英] Call a specific instance of a service in Azure Service Fabric

查看:71
本文介绍了在Azure Service Fabric中调用服务的特定实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务结构应用程序中,我们需要一项服务,该服务需要在操作过程中将一些数据保留在内存中以优化性能,但是在极少数情况下,我们需要清除这些数据.

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?

谢谢

推荐答案

对于Service Fabric Pub/Sub,这似乎是一个完美的用例.只需将需要清除其数据存储器中所有服务的服务都定为订阅者,然后您的呼叫服务就可以发布将广播到所有订阅服务的消息.

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.

在此处查看更多信息: https://github.com/loekd/ServiceFabric.PubSubActors .

See more here: https://github.com/loekd/ServiceFabric.PubSubActors.

这篇关于在Azure Service Fabric中调用服务的特定实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆