Service Fabric StatelessService无法访问同一群集中的StatefulService

时间:2018-11-09 16:43:52

标签: service-fabric-stateful azure-service-fabric

我正在尝试从同一群集中的Web控制器连接到有状态服务。

这些服务部署良好,并且在本地群集上看起来没有问题。

使用的地址也是正确的(它也与Cluster Manager的def相匹配),但是要在 ValuesController 中调用此简单方法:

[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{

// GET api/values
[HttpGet]
public ActionResult<IEnumerable<NodeKey>> GetAll()
{
    var nodeKeyClient = ServiceProxy.Create<ISharedKeysService>(new Uri("fabric:/ReliableCollections/SharedKeys"), new ServicePartitionKey(1), TargetReplicaSelector.PrimaryReplica);
    var keys = nodeKeyClient.GetAllNodeKeys().Result;
    return new ActionResult<IEnumerable<NodeKey>>(keys);
}

我得到一个例外:

  

FabricException:分区的主实例或无状态实例   'd74703d1-d74f-49cc-9457-3ab643063ac4'具有无效的地址,这意味着   副本/实例中的正确地址未在   系统。

SharedKeys 的定义如下:

internal sealed class SharedKeys : StatefulService,ISharedKeysService
{
    public SharedKeys(StatefulServiceContext context)
        : base(context)
    { }

    protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
    {
        return new[] { new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context)) };
    }

我尝试重新启动集群,更改分区号等。 它确实适用于无状态服务。

关于如何解决这个问题的任何想法?

Microsoft.ServiceFabric版本为 6.3.187

Microsoft.ServiceFabric.Services.Remoting为 3.2.187

服务清单定义了以下端点:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="SharedKeysPkg"
                 Version="1.0.0"
                ...

  <Resources>
    <Endpoints>
       <Endpoint Name="ServiceEndpoint" />
       <Endpoint Name="ReplicatorEndpoint" />
    </Endpoints>
  </Resources>
</ServiceManifest>

0 个答案:

没有答案
相关问题