简体   繁体   English

使用percall实例化可能的WCF异步双工回调?

[英]WCF async duplex callbacks possible using percall instancing?

I am using netTcpBinding and from what I have read, percall instance context is the recommended way to use wcf. 我正在使用netTcpBinding,根据我的阅读,percall实例上下文是使用wcf的推荐方法。 However does this mean that I will not be able to use asynchronous duplex callbacks? 但这是否意味着我将无法使用异步双工回调? Because the service objects are destroyed between method calls so there is no way to perform an async callback on the client? 因为在方法调用之间销毁服务对象所以无法在客户端上执行异步回调? Is this correct? 它是否正确?

It seems that if I want to use percall for scalibility, I will be stuck with bad responiveness on client machine because as the callbacks cant be asynchronous. 似乎如果我想使用percall进行可扩展性,我将在客户端计算机上遇到错误的响应,因为回调不能是异步的。 Or have I got it all wrong? 或者我弄错了?

You mix up client instances and server instances. 混合客户端实例和服务器实例。 InstanceContextMode.PerCall means that every call from a client gets a new object serving that single request. InstanceContextMode.PerCall表示来自客户端的每个调用都会获得一个为该单个请求提供服务的新对象。

The callback channel(s) which you are talking about are communicating the other way round: They call methods in your client. 您正在谈论的回调通道正在相反地进行通信:它们在您的客户端中调用方法。 Your client should stay alive and is a single instance from the servers point of view. 从服务器的角度来看,您的客户端应该保持活跃并且是单个实例。

So all you need to persist on the server side after a method call is the clients operation context. 因此,在方法调用之后,您需要在服务器端持久保存客户端操作上下文。 Because thats the reference you need to send a message to your client by using the callback contract. 因为这是您需要使用回调合同向客户端发送消息的引用。

So as a result, you can use async callbacks with InstanceContextMode.PerCall, but you will have to provide some session state storage by yourself. 因此,您可以对InstanceContextMode.PerCall使用异步回调,但您必须自己提供一些会话状态存储。

What do you mean exactly with asynchronous duplex callbacks? 对于异步双工回调,你的意思是什么?

You can use a normal duplex contract and then make calls to this in an asynchronous way so that the client doesn't block. 您可以使用普通的双工合约,然后以异步方式对此进行调用,以便客户端不会阻塞。 Obviously the service object need to stay alive until it has called back to the caller. 显然,服务对象需要保持活动状态,直到它回叫给调用者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM