What is Microsoft Message Queuing (MSMQ)? How does it work?
Asked Answered
S

7

60

I need to work with MSMQ (Microsoft Message Queuing). What is it, what is it for, how does it work? How is it different from web services?

Skillful answered 30/12, 2008 at 12:3 Comment(0)
E
44

As its name states, it's just a queue manager.

You can Send objects (serialized) to the queue where they will stay until you Receive them. It's normally used to send messages or objects between applications in a decoupled way

It has nothing to do with webservices, they are two different things

Info on MSMQ:

https://msdn.microsoft.com/en-us/library/ms711472(v=vs.85).aspx

Info on WebServices:

http://msdn.microsoft.com/en-us/library/ms972326.aspx

Epexegesis answered 30/12, 2008 at 12:9 Comment(1)
The above link on MSMQ did not work (redirected me to some general info page), but this url worked for me msdn.microsoft.com/en-us/library/ms711472(v=vs.85).aspxVicechancellor
F
53

With all due respect to @Juan's answer, both are ways of exchanging data between two disconnected processes, i.e. interprocess communication channels (IPC). Message queues are asynchronous, while webservices are synchronous. They use different protocols and back-end services to do this so they are completely different in implementation, but similar in purpose.

You would want to use message queues when there is a possibility that the other communicating process may not be available, yet you still want to have the message sent at the time of the client's choosing. Delivery will occur the when process on the other end wakes up and receives notification of the message's arrival.

Flofloat answered 30/12, 2008 at 12:20 Comment(1)
Thanks for the respect =) I see MSMQ as a way to send objects from app to app without needing a response passing data for the other app to do whatever it wants, and webservices as a "call to a remote function" with parameters and a result, I used each for these specific purposesEpexegesis
E
44

As its name states, it's just a queue manager.

You can Send objects (serialized) to the queue where they will stay until you Receive them. It's normally used to send messages or objects between applications in a decoupled way

It has nothing to do with webservices, they are two different things

Info on MSMQ:

https://msdn.microsoft.com/en-us/library/ms711472(v=vs.85).aspx

Info on WebServices:

http://msdn.microsoft.com/en-us/library/ms972326.aspx

Epexegesis answered 30/12, 2008 at 12:9 Comment(1)
The above link on MSMQ did not work (redirected me to some general info page), but this url worked for me msdn.microsoft.com/en-us/library/ms711472(v=vs.85).aspxVicechancellor
H
30

Transactional Queue Management 101

A transactional queue is a middleware system that asynchronously routes messages of one sort of another between hosts that may or may not be connected at any given time. This means that it must also be capable of persisting the message somewhere. Examples of such systems are MSMQ and IBM MQ

A Transactional Queue can also participate in a distributed transaction, and a rollback can trigger the disposal of messages. This means that a message is guaranteed to be delivered with at-most-once semantics or guaranteed delivery if not rolled back. The message won't be delivered if:

  • Host A posts the message but Host B is not connected

  • Something (possibly but not necessarily initiated from Host A) rolls back the transaction

  • B connects after the transaction is rolled back

In this case B will never be aware the message even existed unless informed through some other medium. If the transaction was rolled back, this probably doesn't matter. If B connects and collects the message before the transaction is rolled back, the rollback will also reverse the effects of the message on B.

Note that A can post the message to the queue with the guarantee of at-most-once delivery. If the transaction is committed Host A can assume that the message has been delivered by the reliable transport medium. If the transaction is rolled back, Host A can assume that any effects of the message have been reversed.

Web Services

A web service is remote procedure call or other service (e.g. RESTFul API's) published by a (typically) HTTP Server. It is a synchronous request/response protocol and has no guarantee of delivery built into the protocol. It is up to the client to validate that the service has been correctly run. Typically this will be through a reply to the request or timeout of the call.

In the latter case, web services do not guarantee at-most-once semantics. The server can complete the service and fail to deliver a response (possibly through something outside the server going wrong). The application must be able to deal with this situation.

IIRC, RESTFul services should be idempotent (the same state is achieved after any number of invocations of the same service), which is a strategy for dealing with this lack of guaranteed notification of success/failure in web service architectures. The idea is that conceptually one writes state rather than invoking a service, so one can write any number of times. This means that a lack of feedback about success can be tolerated by the application as it can re-try the posting until it gets a 'success' message from the server.

Haiku answered 30/12, 2008 at 13:6 Comment(0)
K
22

Note that you can use Windows Communication Foundation (WCF) as an abstraction layer above MSMQ. This gives you the feel of working with a service - with only one-way operations.

For more information, see: http://msdn.microsoft.com/en-us/library/ms789048.aspx

Ketosis answered 30/12, 2008 at 12:26 Comment(0)
O
8

Actually there is no relation between MSMQ and WebService. Using MSMQ for interprocess communication (you can use also sockets, windows messaging, mapped memory). it is a windows service that responsible for keeping messages till someone dequeue them. you can say it is more reliable than sockets as messages are stored on a harddisk but it is slower than other IPC techniques.

You can use MSMQ in dotnet with small lines of code, Just Declare your MessageQueue object and call Receive and Send methods. The Message itself can be normal string or binary data.

Olenolin answered 30/12, 2008 at 14:1 Comment(0)
L
2

As everyone has explained MSMQ is used as a queue for messages. Messages can be wrapper for actual data, object and anything that you can serialize and send across the wire. MSMQ has it's own limitations. MSMQ 1.0 and MSMQ 2.0 had a 4MB message limit. This restriction was lifted off with MSMQ 3.0. Message oriented Middleware (MOM) is a concept that heavily depends on Messaging. Enterprise Service Bus foundation is built on Messaging. All these new technologies, depend on Messaging for asynchronous data delivery with reliability.

Lionhearted answered 30/12, 2008 at 13:19 Comment(0)
C
0

MSMQ stands for Microsoft Messaging Queue.

It is simply a queue that stores messages formatted so that it can pass to DB (may on same machine or on Server). There are different types of queues over there which categorizes the messages among themselves.

If there is some problem/error inside message or invalid message is passed, it automatically goes to Dead queue which denotes that it is not to be processed further. But before passing a message to dead queue it will retry until a max count and till it is not processed. Then it will be sent to the Dead queue.

It is generally used for sending log message from client machine to server or DB so that if there is any issue happens on client machine then developer or support team can go through log to solve problem.

MSMQ is also a service provided by Microsoft to Get records of Log files. You get Better Idea from this blog http://msdn.microsoft.com/en-us/library/ms711472(v=vs.85).aspx.

Cusack answered 21/7, 2014 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.