Key Benefits of MSMQ [closed]
Asked Answered
T

1

9

I have seen many socket application in which there is use of MSMQ. But when I go in details I think that we can do it without MSMQ also, so I want to know what is key benefit of MSMQ. Why should someone use MSMQ in his own application.

Twelvemo answered 31/1, 2012 at 10:3 Comment(2)
Are you asking why use MSMQ for queueing message rather than some other queueing mechanism, or why queue message rather than just passing them directly to the destination?Confession
Some clues you can find here as well bytes.com/topic/c-sharp/answers/…Chub
M
22

MSMQ is a great piece of Windows. It is basically a message-oriented middleware that helps a lot in some software architectures.

This mainly addresses the common use case of asynchronous message processing: you have a service Service1 that communicates (send messages) with another part of your software architecture, say Service2.

Main problem: what if Service2 becomes suddenly unavailable? Will messages be lost? If you use MSMQ it won't: Service1 will send messages into a queue, and Service2 will dequeue when it is available.

MSMQ will resolve following common issues:

  • temporary unavailability of a service: messages are persisted on the disk and will be dequeued when the service becomes available again, so no messages are lost
  • as it's fully asynchronous, it'll help a lot in case of punctual peak load: your Service2 won't die under the heavy load, it'll just dequeue and process messages, one after one

Pros of MSMQ vs another message-oriented middleware:

  • free and built-in (shipped with Windows)
  • light
  • good integration with other Microsoft products (for instance there is the System.Messaging namespace in .Net to deal with MSMQ)
  • monitoring capabilities (using perfmon counters: number of message received per second...)
  • transactional queues
  • persistence on disk so messages are never lost
  • available through the network (remote queues)
Maisel answered 31/1, 2012 at 10:25 Comment(4)
What if MSMQ suddenly becomes unavailable ? don't we fall into the same trap ?Hammad
@Maisel To grant availability from both services should each of them have a MSMQ in the same server? So Service 2 would read from the MSMQ in the Service 1's server and vice versa?Bronchus
this was a great answer, I can't see why @Maisel hasn't responded these comments.Barmaid
Perhaps ken can elaborate more, but my failures of Service 2 (S2) could mean your service isn't necessarily "gone", but failing to process the items from Service 1 (S1) correctly. We always use queues and don't allow message deletion until completely processed. This way if we created a new version or something weird is happening we have a chance to respond before we lose pertinent data. Lose coupling is nice too.Augmentative

© 2022 - 2024 — McMap. All rights reserved.