Service Fabric Multiple Communication Listeners

大憨熊 提交于 2019-11-30 16:07:15

ok, the solution turned out to be straight forward but not obvious. The docs seem to encourage port sharing approach even though the TCP/RPC and HTTP don't play together.

Basically, I added a second endpoint to the service manifest even though the docs say that each service can only listen on one port.

I left the default / first endpoint for the ServiceRemotingListener to register and added a second that listened specifically to port 8083.

<Endpoint Name="ServiceEndpoint" Protocol="http" Type ="Input"/>
<Endpoint Name="ServiceEndpoint2" Protocol="http" Port="8083" Type ="Input"/>

Then in the IOwinCommunicationsListener, I specified the second endpoint which picked up the alternative port number (I assumed the ServiceInstanceListener would use the default/first end point).

var codePackageActivationContext = this.serviceInitializationParameters.CodePackageActivationContext;
var port = codePackageActivationContext.GetEndpoint("ServiceEndpoint2").Port;

The CreateServiceInstanceListeners were left without any extra config. As above, I wonder if I could use the ServiceRemoteListenerSettings to force the ServiceRemotinglistener to use the alternative port instead of the IOwinCommunicationsListener above)

        return new[]
        {
            new ServiceInstanceListener(initParams => new ServiceRemotingListener<Interfaces.IConfig>(initParams, this),"MyRpc"),
            new ServiceInstanceListener(initParams => new OwinCommunicationListener("ShopifyWebService", new Startup(_options, this), initParams),"MyOwin")
               };

Hope this helps save someone else a lot of time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!