Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we speed up receiving messages from MSMQ?

My application's bottleneck has become sending and receiving messages over MSMQ with MassTransit. 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. We are not doing any work in Enqueue() except time how quickly messages are being sent.

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. Each messages is <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?

like image 915
Chris Avatar asked Dec 18 '13 16:12

Chris


1 Answers

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.) . Refer this msdn link.

like image 88
Sreejith Nair Avatar answered Sep 20 '22 13:09

Sreejith Nair