本文介绍了System.Messaging - 为什么的MessageQueue不提供发送的异步版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会有人知道为什么System.Messaging不提供发送方法来发送一个MSMQ消息队列的异步版本。

Would anyone know why System.Messaging is not offering an asynchronous version of the Send method to send an MSMQ message to a queue.

实际上有窥视的异步版本和接收的方法(通过开始可以转换到一个C#5异步awaitable方法/结束对),但surprinsingly没有BeginSend / EndSend方法提供,只是这似乎发送方法对我来说,这是一个同步阻塞I / O调用。

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.

我觉得这不是System.Messaging的限制,而是本地的消息队列API之一(mqrt.dll),该System.Messaging使用这需要一个重叠结构,在功能上参数MQReceiveMessage 使用重叠I / O与IOCP,而功能 MQsendMessage 不采取这样的结构,这样看起来就像是一个纯粹的同步调用。

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.

不过我的问题是,没有人会知道为什么的MessageQueue API不提供发送消息到一个队列的异步方式?

Still my question remains, anyone would know why MessageQueue API does not offer an asynchronous way of sending a message to a queue ?

推荐答案

的指出的发送是永远的异步操作。它已经有一段时间,因为我已经与MSMQ的工作,但IIRC只要你发送的消息刷新到磁盘之前当地甚至试图通过网络发送。

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.

这篇关于System.Messaging - 为什么的MessageQueue不提供发送的异步版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:39