Service Fabric .net core remoting с использованием версии 2.1 - PullRequest
0 голосов
/ 19 сентября 2019
    I'm trying to get started with learning Service Fabric. Most of the tutorials and demo's referring to remoting being the fastest form of communication between services and the easiest to do.  

    I followed the documentation found here focusing on the part about using the newer version 2.1
    [Service Remoting](https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication-remoting#call-remote-service-methods)

    I did find out through other sources that v1 is restricted to .net framework, and V2 to .net core.  Version 2 also makes use of an attribute.  The instructions seem to make it fairly clear even though they only cover how to do it with a stateless service.  I did find a couple of articles that gave snippets about how to get it to work with Stateful services and it is a bit different but not much.  Still something isn't working as whenever I try to talk with it I get an "Invalid name url" exception.

Я выкладываю здесь все, казалось бы, важные фрагменты моего проекта.

Я думаю, что я близок к этому, но я не могу найти ни одного законченного примера проекта, который помог бы мне понять, что мне не хватает.
'' 'с использованием Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime;использование Microsoft.ServiceFabric.Services.Remoting.FabricTransport;использование Microsoft.ServiceFabric.Services.Remoting;использование Microsoft.ServiceFabric.Services.Runtime;используя System.Fabric;использование Microsoft.ServiceFabric.Services.Communication.Runtime;

        [assembly: FabricTransportServiceRemotingProvider(RemotingListenerVersion = RemotingListenerVersion.V2_1 | RemotingListenerVersion.V2, RemotingClientVersion = RemotingClientVersion.V2_1)]

        namespace TestStatefulService
        {
        public class TrialService : StatefulService, ITestStatefull
        {
            public TrialService(StatefulServiceContext context)
                : base(context)
            {
            }
            public Task<string> HelloWorld()
            {
                return Task.FromResult("Hello World");
            }

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

'''
<Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Name="ServiceEndpoint" />

      <!-- This endpoint is used by the replicator for replicating the state of your service.
           This endpoint is configured through a ReplicatorSettings config section in the Settings.xml
           file under the ConfigPackage. -->
      <Endpoint Name="ReplicatorEndpoint" />
      <Endpoint Name="ServiceEndpointV2_1" />
    </Endpoints>
  </Resources>
'''

'''
[assembly: FabricTransportServiceRemotingProvider(RemotingListenerVersion = RemotingListenerVersion.V2_1, RemotingClientVersion = RemotingClientVersion.V2_1)]
namespace P4PInterfaces
{
    public interface ITestStatefull : IService
    {
        Task<string> HelloWorld();
    }
}
'''


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

                ITestStatefull service = proxyFactory.CreateServiceProxy<ITestStatefull>(new Uri("fabric:/P4PSF/TestStatefulService/"), new ServicePartitionKey(1));

                var hello = await service.HelloWorld();
'''

1 Ответ

0 голосов
/ 26 сентября 2019

Оказалось, мой код отображается просто отлично.Проблема была в том, что несколько слушателей были определены, но не настроены должным образом, поэтому Service Fabric запуталась.

...