Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message queues vs sockets

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.

like image 574
Sara Avatar asked May 19 '12 18:05

Sara


People also ask

Do message queues decrease performance?

Message queues can significantly simplify coding of decoupled applications, while improving performance, reliability and scalability.

What is the difference between message queue and message broker?

Message queues provide means for the different applications to push information to the queue. The message broker simply takes the information from the sender, translates it between different messaging protocols, if needed, and delivers the message to the correct receiver.

Is message queue faster than shared memory?

Shared memory can be deemed as faster (low overhead, high volume of data passing) then queues. But queues on the other hand, requires high overhead (the set up for making a queue to be permanent etc) with low volume of data.

Do message queues increase complexity?

Cons. Increased Complexity: Introduction of message queues to a system architecture increases the overall complexity of the system. Ensuring data consistency and managing the network between the components For simple applications with a limited number of users, message queues might be an overkill.


1 Answers

The two are incomparable, as they represent different layers. It's like comparing a relational database to a file on a disk or comparing a house to a brick (i.e. certainly you need files to build databases and bricks to build houses, and sometimes all you need is a file or a brick, but that does not make them comparable).

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 a low-level network abstraction that says: "currently two programs can send data over a network to each other, at least until connection breaks for some reason". So yes, usually a messaging queue will use a socket connection to work across a network.

By the way: MDB (Message Driven Bean) that you mention is not a message queue (just like JDBC isn't a databasae). It's an API for consuming transactional messages. They may come from a queue, but they don't have to.

like image 176
fdreger Avatar answered Sep 19 '22 07:09

fdreger