10

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?

Francesco Cristallo
  • 2,856
  • 5
  • 28
  • 57

1 Answers1

11

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.

LoekD
  • 11,402
  • 17
  • 27
  • could you give some details on how to call this once setup? As in the client side. – Choco Nov 23 '17 at 04:16
  • Create a ServiceProxy using the service url, and partition key (if stateful) https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting#call-remote-service-methods – LoekD Nov 24 '17 at 07:24
  • 1
    I've done this and it still doesn't work. This answer just repeats what's in the tutorial mentioned above on learn.microsoft.com – Alex Marshall Apr 22 '18 at 02:10
  • Important point is that "[assembly: FabricTransportServiceRemotingProvider(RemotingListener = RemotingListener.V2Listener, RemotingClient = RemotingClient.V2Client)]" should also be added to the client assembly, not only service. – Maxim Alexeyev Sep 28 '18 at 20:09
  • I ended up having to do return Microsoft.ServiceFabric.Services.Remoting.Runtime.ServiceRemotingExtensions.CreateServiceRemotingReplicaListeners(this); and inheriting from IService – AlignedDev Nov 13 '19 at 20:05