简体   繁体   English

我们如何加快从MSMQ接收消息?

[英]How can we speed up receiving messages from MSMQ?

My application's bottleneck has become sending and receiving messages over MSMQ with MassTransit. 我的应用程序的瓶颈已经变成通过MassTransit通过MSMQ发送和接收消息。 The send and receive are both happening within the same application, but there are often too many messages to use an in-memory queue. 发送和接收都发生在同一个应用程序中,但是通常有太多消息要使用内存中队列。

Here is my simple queue setup: 这是我的简单队列设置:

messageBus = ServiceBusFactory.New(sbc =>
                {
                    sbc.UseMsmq();
                    sbc.VerifyMsmqConfiguration();
                    sbc.UseMulticastSubscriptionClient();
                    sbc.ReceiveFrom("msmq://localhost/msg_queue");
                    sbc.Subscribe(subs =>
                    {
                        subs.Handler<EventMessage>(msg => Enqueue(msg));
                    });
                });

For my experiments, MSMQ currently has ~1 million messages and we are not pushing any new messages to it. 对于我的实验,MSMQ目前有大约100万条消息,我们没有向它推送任何新消息。 We are not doing any work in Enqueue() except time how quickly messages are being sent. 我们没有在Enqueue()做任何工作,除了时间消息的发送速度。

With that information, we can only grab between 150 and 200 messages per second from MSMQ, when I'd hoped it would be at least 1000 messages per second when there is no network latency. 有了这些信息,我们每秒只能从MSMQ中获取150到200条消息,当我希望在没有网络延迟时每秒至少有1000条消息。 Each messages is <2kb. 每条消息<2kb。

How can we speed up how quickly MSMQ passes messages to an application over MassTransit while maintaining the message ordering enforced by a queue? 我们如何加快MSMQ通过MassTransit将消息传递给应用程序的速度,同时保持队列强制执行的消息排序?

I did addressed something similar before. 我以前做过类似的事情。 If I remember it correctly, We specified message expiration through TimeToBeReceived (The total time for a sent message to be received from the destination queue. The default is InfiniteTimeout.) . 如果我没记错的话,我们通过TimeToBeReceived指定了消息到期时间(从目标队列接收已发送消息的总时间。默认为InfiniteTimeout。)。 Refer this msdn link . 请参阅此msdn链接

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

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