问题
Consider a most simple client/server callback setup using netTcpBinding
Server:
_callback.BeginReceive(message, EndCallbackClient, null);//send message to client
Client :
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Single, UseSynchronizationContext=false)]
public class TradingClient : ITradingClientCallback, IDisposable
{
public void Receive(Message message)
{
//handle message
}
Please note <reliableSession ordered="true"/>
is not in the WCF config
If, for example, the client side froze for a moment and a number of messages were sent from the server could the client Receive
them out of order?
I have attempted to simulate this but have been unable to reproduce a scenario where they are out of order, however I had a random application error previously that indicated it might have happened.
Intuitively thinking about how sockets work I would have said this isnt possible but having a look at the client-side message callback reveals lots of code:
I know the messages are being sent in the correct order server-side and I know that if written to the socket in order they will be read off the socket in the correct order client-side - however as indicated by the red arrow theres lots of WCF code after the async socket read that I'm wondering if 2 (or more) messages read off the wire could result in out of order messages at the app level.
来源:https://stackoverflow.com/questions/39502340/can-wcf-nettcpbinding-callbacks-return-out-of-order