簡體   English   中英

Service Fabric具有不同ContractDescriptions的多個ServiceEndpoint

[英]Service Fabric multiple ServiceEndpoints with different ContractDescriptions

我已經建立了帶有無狀態服務和Web API的基本Service Fabric解決方案,並測試了使用默認服務遠程偵聽器可以正常運行的一切。 快樂的時光!

當我嘗試用服務總線中繼替換默認的偵聽器(我打算如何與服務通信)時,在啟動時遇到錯誤。

CreateServiceInstanceListeners()

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[] { 
        new ServiceInstanceListener(context => {
            var wcfRelay = new WcfCommunicationListener<ICommercial>(
                wcfServiceObject: this,
                serviceContext: context,
                endpointResourceName: "serviceRelay");

            return wcfRelay;
        })
    };
}

服務配置(app.config)

  <system.serviceModel>
    <extensions>…</extensions>
    <services>
      <service name="Commercial.Service.CommercialService">
        <endpoint address="http://[namespace].servicebus.windows.net/CommercialService" 
                  name="serviceRelay" 
                  binding="basicHttpRelayBinding" 
                  contract="Commercial.Interface.ICommercial" 
                  behaviorConfiguration="relayToken" />
      </service>
    </services>
    <bindings>
      <basicHttpRelayBinding>
        <binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" maxBufferSize="5886800" maxBufferPoolSize="524288" maxReceivedMessageSize="5886800" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="5886800" maxArrayLength="5886800" maxBytesPerRead="5886800" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpRelayBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="relayToken">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedAccessSignature keyName="RootManageSharedAccessKey" key="[key]" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

如果我中斷了偵聽器的創建,則會看到它正在創建兩個服務端點:

在此處輸入圖片說明

最終,我在Service Fabric資源管理器中為每個節點顯示此錯誤。

不正常的事件:SourceId ='System.RA',Property ='ReplicaOpenStatus',HealthState ='Warning',ThoughtWarningAsError = false。 副本在in_Node_1 API調用中發生多個故障:IStatelessServiceInstance.Open(); 錯誤= System.InvalidOperationException(-2146233079)服務包含具有不同ContractDescription的多個ServiceEndpoint,每個ContractDescription的Name ='ICommercial'和Namespace =' http:// [schema_path] / 20170713 '。 為ContractDescriptions提供唯一的名稱和命名空間,或者確保ServiceEndpoint具有相同的ContractDescription實例。 位於System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description,ServiceHostBase serviceHost)處於System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription,ServiceHost Description,ServiceHostBase serviceHostBase) )在System.ServiceModel.ServiceHostBase.InitializeRuntime()在System.ServiceModel.ServiceHostBase.OnBeginOpen(TimeSpan超時,AsyncCallback回調,對象狀態)在System.ServiceModel.Channels.CommunicationObject.OpenAsyncResult.InvokeOpen()在System.ServiceModel.Channels。 Microsoft.ServiceFabric.Services.Communication上的CommunicationObject.OpenAsyncResult..ctor(CommunicationObject communicationObject,TimeSpan超時,AsyncCallback回調,對象狀態)在System.ServiceModel.Channels.CommunicationObject.BeginOpen(TimeSpan超時,AsyncCallback回調,對象狀態) .Wcf.Runtime.WcfCommunicationListener`1.Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__20.MoveNext()處的Microsoft.ServiceFabric.Services.Communication.Runtime.ICommunicationListener.OpenAsync(CancellationToken cancellingToken)-從堆棧跟蹤結束拋出異常的先前位置---在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)處System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() )

我還不清楚如何解決此問題“要么為ContractDescriptions提供唯一的名稱和命名空間,要么確保ServiceEndpoint具有相同的ContractDescription實例”。

EndpointResourceName應該絕對指向您在ServiceManifest文件中指定的端點。 無論如何,我什至不知道app.config甚至在這里都可以工作...您是否看到過任何使用app.confing的WCF偵聽器的SF示例? 看看這個不錯的示例,以在代碼-ServiceFabric.WcfCalc中配置所需的設置。 希望它會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM