我正在尝试编写一个服务解析器,为此,我目前正在使用https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication中提到的ServicePartitionResolver
。
到目前为止,这一切都很好。有了我的服务信息,我就能解决这样的服务:
var resolvedService = await ServicePartitionResolver.GetDefault().ResolveAsync(service.ServiceName, key, CancellationToken.None);
现在,为了允许我的服务相互通信,我正在第一个读取端点地址,例如:
resolvedService.Endpoints.First().Address
这将正确返回我在OpenAsync
实现的ICommunicationListener
方法中返回的必需端点。
基本上,只要协议为http,这一切都做得很好。
一旦我将协议切换到服务的ServiceManifest.xml中的tcp之类的内容,请求就应该发送到该地址:
<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 Protocol="tcp" Name="ServiceEndpoint" Type="Input" Port="3245" />
</Endpoints>
ServiceResolver
仍然将我的端点解析为以http
开头的地址。
那么,现在我的问题-我是在做错什么吗?因为在我看来,我似乎真的无法确切地知道要处理的端点。即使这没有直接反映在地址中,我仍然可以只修剪端点字符串中的http部分,但是也没有信息表明它是哪种端点。因此,从技术上讲,我可以将http://
替换为空白,但是最好基于从Service Fabric返回的内容而不是“因为我知道端点”来执行此操作。
有什么想法吗?