【问题标题】:Invoke same method on all active instances of a stateless service在无状态服务的所有活动实例上调用相同的方法
【发布时间】:2018-12-16 23:50:03
【问题描述】:

在 SFC 中对无状态服务的所有活动实例调用相同方法的最佳方法是什么? 我的意思是在所有活动实例上执行类似于下面的操作:

var service = ServiceProxy.Create<IMyService>("<my-service-uri>");
await service.MyServiceMethod();

【问题讨论】:

  • 调用方法是什么意思?您是在尝试对服务进行远程调用还是在谈论 HTTP 调用?
  • 我的意思是每个活动实例的远程调用。扩展问题以提供更多详细信息。

标签: azure-service-fabric service-fabric-stateless


【解决方案1】:

不幸的是,似乎无法将远程请求发送到特定的服务实例/副本。

根据ServiceProxy.Create 方法的文档,对目标实例/副本选择的控制非常有限(严格限制TargetReplicaSelector 枚举)。

【讨论】:

  • 我希望我能得到所有实例的列表,就像我可以使用 FabricClient 和 ServicePartitionResolver 遍历节点、分区等一样。然后,我将使用远程处理一一调用该方法。除了常规的 ServiceProxy... 类之外,我可能还需要使用其他东西
  • @filip 据我所知,没有 ServiceProxy 就无法使用远程处理进行通信。如果您发现这里的方法是获取有关每个副本的信息(包括其 id 等)的代码 - var client = new FabricClient(); foreach (var partition in await client.QueryManager.GetPartitionListAsync(new Uri("&lt;service-name&gt;"))) { foreach (var replica in await client.QueryManager.GetReplicaListAsync(partition.PartitionInformation.Id)) { // Here you have replica information } }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-14
  • 1970-01-01
  • 1970-01-01
  • 2013-10-04
  • 1970-01-01
  • 2019-05-19
  • 1970-01-01
相关资源
最近更新 更多