Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何设置在Azure远程群集上工作的可靠服务_Azure_Listener_Actor_Azure Service Fabric_Endpoint - Fatal编程技术网

如何设置在Azure远程群集上工作的可靠服务

如何设置在Azure远程群集上工作的可靠服务,azure,listener,actor,azure-service-fabric,endpoint,Azure,Listener,Actor,Azure Service Fabric,Endpoint,我制作了一个可靠的服务应用程序,可以在本地集群上完美运行 它有1个无状态服务和1个参与者服务,并且都使用服务远程处理。 这些服务上未定义端点(仅端点名称),并且两个服务都使用默认侦听器(无CreateServicesListeners覆盖) 客户端应用程序是一个控制台应用程序,它使用服务远程处理与应用程序(ActorProxy和ServiceProxy)通信 现在我想在Azure集群上部署它 我应该如何使客户端与集群上的应用程序正确通信 我知道我必须: 在xml设置上配置TCP端点 配置Azu

我制作了一个可靠的服务应用程序,可以在本地集群上完美运行

它有1个无状态服务和1个参与者服务,并且都使用服务远程处理。 这些服务上未定义端点(仅端点名称),并且两个服务都使用默认侦听器(无CreateServicesListeners覆盖) 客户端应用程序是一个控制台应用程序,它使用服务远程处理与应用程序(ActorProxy和ServiceProxy)通信

现在我想在Azure集群上部署它

我应该如何使客户端与集群上的应用程序正确通信

我知道我必须:

  • 在xml设置上配置TCP端点
  • 配置Azure负载平衡器
但是我应该这样做吗?那怎么办

  • 重写CreateServiceListeners
  • 在客户端上使用FabricClient
  • 在客户端上使用ServicePartitionClient

我的主要问题是如何创建ActorProxy和ServiceProxy

您不应该在集群之外使用ActorProxy和ServiceProxy类。取而代之的是使用面向公众的服务,例如使用https作为服务网关的Web Api。然后打开Azure负载平衡器上的https端口

请阅读,因为他们列出了你需要采取的每一步

这是一个使用https的服务示例(摘自文档):

class HttpCommunicationListener : ICommunicationListener
{
    ...

    public Task<string> OpenAsync(CancellationToken cancellationToken)
    {
        EndpointResourceDescription endpoint =
            serviceContext.CodePackageActivationContext.GetEndpoint("WebEndpoint");

        string uriPrefix = $"{endpoint.Protocol}://+:{endpoint.Port}/myapp/";

        this.httpListener = new HttpListener();
        this.httpListener.Prefixes.Add(uriPrefix);
        this.httpListener.Start();

        string publishUri = uriPrefix.Replace("+", FabricRuntime.GetNodeContext().IPAddressOrFQDN);
        return Task.FromResult(publishUri);
    }

    ...
}

class WebService : StatelessService
{
    ...

    protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
    {
        return new[] { new ServiceInstanceListener(context => new HttpCommunicationListener(context))};
    }

    ...
}
HttpCommunicationListener类:ICommunicationListener { ... 公共任务OpenAsync(CancellationToken CancellationToken) { EndpointResourceDescription端点= serviceContext.CodePackageActivationContext.GetEndpoint(“WebEndpoint”); 字符串URI前缀=$“{endpoint.Protocol}://+:{endpoint.Port}/myapp/”; this.httpListener=新的httpListener(); this.httpListener.Prefixes.Add(uriPrefix); this.httpListener.Start(); 字符串publishUri=uriPrefix.Replace(“+”,FabriRuntime.GetNodeContext().IPAddressOrFQDN); 返回Task.FromResult(publishUri); } ... } 类WebService:无状态服务 { ... 受保护的重写IEnumerable CreateServiceInstanceListeners() { 返回new[]{new ServiceInstanceListener(context=>new-HttpCommunicationListener(context))}; } ... } 像上面这样的公共服务应该使用ActorProxy和ServiceProxy类将工作委托给底层服务和参与者

因此,总结一下:

但是我应该这样做吗?那怎么办

  • 覆盖CreateServiceListeners

  • 在客户端上使用FabricClient

  • 在客户端上使用ServicePartitionClient

我的主要问题是如何创建ActorProxy和ServiceProxy这只适用于集群中服务之间的通信


所以你们所说的是将这个Api用作网关,我过去通过服务远程调用的每个方法现在都必须通过Api调用,对吗?我现在有一些问题:我的应用程序是一个在线游戏,我的客户端是一个控制台应用程序。它使用远程方法与无状态服务(登录服务)和参与者服务(游戏会话)交互。我的客户机现在如何调用Api方法(作为客户机和服务方法之间的接口)并接收这些服务方法的返回值?我的客户使用了演员事件。我的客户端现在将如何接收它?您的客户端可以像调用任何其他服务一样,通过使用具有正确端口号的群集FQDN来调用web/wcf api。揭露演员事件可能更具挑战性。可以选择使用信号器或侦听器作为服务可以调用的客户端