Would anyone know why System.Messaging is not offering an asynchronous version of the Send method to send an MSMQ message to a queue.
Actually there is asynchronous version of Peek and Receive methods (via Begin/End pairs that can be converted to a C#5 async awaitable method), but surprinsingly there is no BeginSend/EndSend methods offered, just a Send method which seems to me like it's a synchronous blocking I/O call.
I think this is not a limitation of System.Messaging but rather one of the native messaging queue API (mqrt.dll) that System.Messaging is using which takes an overlapped structure as a parameter in function MQReceiveMessage
to use overlapping I/O with IOCP, whereas function MQsendMessage
does not take such structure so seems like it's a purely synchronous call.
Still my question remains, anyone would know why MessageQueue API does not offer an asynchronous way of sending a message to a queue ?
The MSMQ documentation states that a send is "always an asynchronous operation". It's been a while since I've worked with MSMQ, but IIRC as soon as you send, the message is flushed to disk locally before it even attempts to send over the network.
So, while it's not truly asynchronous (it has to wait for the disk write), it should be fairly fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With