2016-05-04 25 views
2

WCFCommunicationListenerを使用してステートフルな信頼性の高いサービスの例を見つけたことはありませんでした。私は私の切断は、あなたが運営契約を実装する場所だと思います。それはメインのサービスクラスで行われますか?サービスにsvcファイルを追加することはできません。したがって、クライアントがWCFCommunicationListenerを呼び出すときにトリガーされる別のクラスである必要があると想定します。サービスファブリックWCF通信による信頼性の高いサービス

答えて

5

はい、それはメインのサービスクラスにプログラムで行われています。 https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-communication-wcf/

は、基本的にはちょうどこの:

[ServiceContract] 
interface IAdderWcfContract 
{ 
    // 
    // Adds the input to the value stored in the service and returns the result. 
    // 
    [OperationContract] 
    Task<double> AddValue(double input); 

    // 
    // Resets the value stored in the service to zero. 
    // 
    [OperationContract] 
    Task ResetValue(); 

    // 
    // Reads the currently stored value. 
    // 
    [OperationContract] 
    Task<double> ReadValue(); 
} 

class MyService: StatefulService, IAdderWcfContract 
{ 
    ... 
    CreateServiceReplicaListeners() 
    { 
     return new[] { new ServiceReplicaListener((context) => 
      new WcfCommunicationListener<IAdderWcfContract>(
       wcfServiceObject:this, 
       serviceContext:context, 
       // 
       // The name of the endpoint configured in the ServiceManifest under the Endpoints section 
       // that identifies the endpoint that the WCF ServiceHost should listen on. 
       // 
       endpointResourceName: "WcfServiceEndpoint", 

       // 
       // Populate the binding information that you want the service to use. 
       // 
       listenerBinding: WcfUtility.CreateTcpListenerBinding() 
      ) 
     )}; 
    } 

    // implement service methods 
    ... 
} 
+0

うん、あなたがこのドキュメントに従うならば行うことはかなり簡単でなければなりません。私は投稿後にこれを理解しました。しかし、良い答えをありがとう! –

関連する問題