Service Fabric Stateful Service Remoting V2

2020-06-03 03:47发布

I have a Stateful Service called by a Stateless service, in .Net Standard Asp.net Core 2.0 running on Visual Studio 15.4. I can't make the Service Remoting V2 work.

The old code in the Stateful service that worked for V1 is not valid anymore

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

I tried to follow this tutorial but the example is for the stateless one.

I tried to change the code in this without success.

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
    {
        return new List<ServiceReplicaListener>()
            {
                new ServiceReplicaListener((c) =>new FabricTransportServiceRemotingListener(c, this))
            };
    }

Also there are no instructions on how or where to use this code in the tutorial

var proxyFactory = new ServiceProxyFactory((c) =>
   {
       return new FabricTransportServiceRemotingClientFactory();
   });

I'm stuck, could someone show me how to make it work?

1条回答
再贱就再见
2楼-- · 2020-06-03 04:03

In your stateful service, in method CreateServiceReplicaListeners, use this code:

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
    return this.CreateServiceRemotingReplicaListeners();
}

And in the file that defines your remoting service interface, add this:

[assembly: FabricTransportServiceRemotingProvider(RemotingListener = RemotingListener.V2Listener, RemotingClient = RemotingClient.V2Client)]

(for example, just below the using namespaces list.)

Add the endpoint: <Endpoint Name="ServiceEndpointV2" />

And rebuild the client.

查看更多
登录 后发表回答