[英]Service Fabric Reliable Service with WCF communication
I haven't had much luck finding an example of a Stateful Reliable Service using the WCFCommunicationListener. 使用WCFCommunicationListener来查找有状态可靠服务的示例并不太幸运。 I guess my disconnect is where you implement the Operation Contracts.
我想我的脱节是您执行运营合同的地方。 Is it done in the main service class?
是在主服务类中完成的吗? You can't add an svc file to the Service, so I assume it has to be some other class that is triggered when the client calls the WCFCommunicationListener.
您无法将svc文件添加到服务,因此我认为它必须是客户端调用WCFCommunicationListener时触发的其他某个类。
Yes, it's done programmatically on the main service class. 是的,它是在主要服务类上以编程方式完成的。 Should be fairly simple to do if you follow this doc: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-communication-wcf/
如果您遵循此文档,则应该做起来非常简单: https : //azure.microsoft.com/zh-cn/documentation/articles/service-fabric-reliable-services-communication-wcf/
Basically just this: 基本上就是这样:
[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
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.