I saw here (Wikipedia article about IPC) that these are two separate things, but even reading each one's dedicated Wikipedia page I didn't understand what the difference is.
Can someone explain this simply?
In a message queue, a writer process can write a message and exit. A reader process can read a message later. A pipe is deleted from the system if there is no linked receiver/sender process is present. A message queue remains active in the system until explicitly deleted by some process.
Message queue has inherent synchronization overhead, guarantee of safety at cost of performance. Shared memory has no safeguards - if two threads access it simultaneously, they will possibly conflict (write inconsistent data) unless you assure thread safety yourself.
A Message Queue is a mechanism for sharing information, between processes, threads, systems. An AppEngine task Queue is a way for an AppEngine application to say to itself, I need to do this, but I am going to do it later, outside of the context of a client request.
Web browsers and web servers are examples of processes that communicate by message-passing. A URL is an example of referencing a resource without exposing process internals. A subroutine call or method invocation will not exit until the invoked computation has terminated.
Message passing is a very general term. It can be examined from different aspects, one of those is how data is transferred from the sender to the receiver:
Synchronous message passing: the sender and the receiver have to "meet" at their respective send
/receive
operations in order that data can be transferred. This is also called 'rendezvous' or 'handshaking'. This form of transfer is simple, but might be inefficient because the sender may have to wait even if it has done its duty and prepared the data to be sent.
Asynchronous message passing: the sender does not wait for the receiver to reach its receive
operation, rather it gets rid of the prepared data and continues its execution. This form of transfer does not force the sender to wait, but creates another problem: there may be messages that have already been sent but not yet received, and they have to be stored somewhere. This is where message queues come into play, they are the buffers for in-transit messages.
So, the answer to your question is that message queues are used/needed when message passing is done asynchronously rather than synchronously.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With