Udostępnij za pośrednictwem


OperationContractAttribute.IsOneWay: One more blocking scenario.

As I mentioned in the previous post, there are scenarios in which one-way operations can block a client. After investigation I've discovered yet another, shown to me by John Justice, Michael Marucheck, and Ed Pinto.

The scenario is quite specific. The client can block on the service when the ConcurrencyMode is set to ConcurrencyMode.Single and the binding has established a session of any type (that is, it implements ISessionChannel<ISession>). The reason is that in this case, the dispatcher enforces ordering on such messages. For example, in the case of HTTP-based one-way operations (remember that WSHttpBinding is the recommended default binding), a first message comes in from the client and while the service is processing the message the transport sends back an HTTP 202, enabling the client transport to return and unblocking the WCF client object. The WCF client object can then make the call again.

If the second call arrives while the service is still processing the first message, the second call is blocked until the service frees up. This, in turn, prevents the HTTP 202 message from being sent back until the dispatcher begins to process the second message. Should those calls come in too fast, the client will begin to block. 

If I come up with any more, I'll let you know. Cheers, me.