简体   繁体   English

Service Fabric .net 核心远程处理使用版本 2.1

[英]Service Fabric .net core remoting using version 2.1

    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.

I'm posting all the seemingly relevant bits from my project here.我在这里发布了我项目中所有看似相关的部分。

I think I'm close on this one but I can't find any complete sample projects to help me figure out what it is that I'm missing.我想我已经接近这个了,但我找不到任何完整的示例项目来帮助我弄清楚我错过了什么。
''' using Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime; ''' 使用 Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime; using Microsoft.ServiceFabric.Services.Remoting.FabricTransport;使用 Microsoft.ServiceFabric.Services.Remoting.FabricTransport; using Microsoft.ServiceFabric.Services.Remoting;使用 Microsoft.ServiceFabric.Services.Remoting; using Microsoft.ServiceFabric.Services.Runtime;使用 Microsoft.ServiceFabric.Services.Runtime; using System.Fabric;使用 System.Fabric; using Microsoft.ServiceFabric.Services.Communication.Runtime;使用 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();
'''

It turned out my code displayed was just fine.事实证明我显示的代码很好。 The problem I has was multiple listeners defined but not setup properly so Service Fabric was getting confused.我遇到的问题是定义了多个侦听器但未正确设置,因此 Service Fabric 变得混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Service Fabric .NET Core 2.1服务通信 - Service Fabric .NET Core 2.1 service communications 服务结构服务远程处理 - Service Fabric Service Remoting 如何使用 .Net Remoting 使 .Net Core 客户端应用程序与 .Net Framework 服务通信 - How to make .Net Core client app communicate to a .Net Framework service using .Net Remoting 使用WCF或.Net Remoting服务的Windows服务 - Windows service using WCF or .Net Remoting service 如何配置.NET Core 2.1服务结构服务以在应用程序洞察中自动使用请求和依赖关系跟踪 - How do I configure a .NET Core 2.1 service fabric service to automatically use request and dependency tracking in application insights 使用通用参数的Azure Service Fabric Remoting - Azure Service Fabric Remoting with generic parameter 如何结合 Service Fabric Remoting 进行分区 - How to do partitioning in combination with Service Fabric Remoting 通过服务中的.NET远程连接到服务 - connect to a service with .NET remoting in a service 从.net Core 2.1中的单例服务注入范围服务 - Injecting scoped service from singleton service in .net core 2.1 如何使用Topshelf将asp.net Core 2.1 MVC应用程序部署为Windows服务 - How to deploy asp.net core 2.1 MVC application as windows service using topshelf
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM