Message queues vs sockets

Sara picture Sara · May 19, 2012 · Viewed 20.4k times · Source

I don't have much of a socket programming experience but I tried read a little about it. I am quite familiar with MDB and messaging queues. Someone has told me that queue(e.g. MDB) is "Not much more than a direct socket connection". Can someone compare these two for me.

Answer

fdreger picture fdreger · May 19, 2012

eeeeemph... this someone was very wrong. The two are incomparable, as they live in different layers. It's like saying that "a relational database is not much more than a file on a disk" or "a house is not much more than a brick".

Messaging queue is a piece of software that glues senders and receivers so that they can communicate without knowing much about each other (they both need to know about the queue, of course) and do not need to implement networking code, handling failure, routing one message to many receivers etc. The system works even if senders and receivers are never alive at the same time, as queues also serve as a temporary storage for undelivered messages. Aside from that, queues can provide additional services, like authorization, transactions etc.

A socket connection is just a low-level abstraction that says: "currently two programs can send data over network to each other, at least until connection breaks for some reason". So yes, usually a messaging queue will use socket connections in order to work.