Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does AMQP overcome the difficulties of using TCP directly?

How does AMQP overcome the difficulties of using TCP directly when sending messages? Or more specifically in a pub/sub scenario?

like image 625
user1577433 Avatar asked Feb 28 '13 23:02

user1577433


People also ask

Does AMQP use TCP?

AMQP 0-9-1 is an application level protocol that uses TCP for reliable delivery.

Does AMQP use TCP or UDP?

Protocol dependencies Protocol is currently defined to use TCP as its transport protocol. In the future SCTP is going to be supported as transport protocol as well. IANA-assigned port number for AMQP is 5672 (TCP, UDP, SCTP).

What is AMQP protocol and how it works?

The Advanced Message Queuing Protocol (AMQP) is an open standard for passing business messages between applications or organizations. It connects systems, feeds business processes with the information they need and reliably transmits onward the instructions that achieve their goals.

Is AMQP protocol secure?

AMPQ is efficient, portable, multichannel and secure. The binary protocol offers authentication and encryption by way of SASL or TLS, relying on a transport protocol such as TCP. The messaging protocol is fast and features guaranteed delivery with acknowledgement of received messages.


2 Answers

In AMQP there is a broker, that broker receives the messages and then does the hard part about routing them to exchanges and queues. You can also setup durable queues which save the messages for clients even when they are disconnected.

You could certainly do all this yourself, but it's a tremendous amount of work to do correctly. RabbitMQ in particular has been battle tested in many deployments.

You are still using the TCP protocol underneath AMQP, AMQP provides a higher abstraction.

You would also have to choose a wire protocol to use with all your clients, where AMQP already defines that wired protocol.

like image 80
hwatkins Avatar answered Oct 09 '22 11:10

hwatkins


It overcomes difficulties by using one and same TCP connection for all of your threads for performance. AMQP is able to do it by using channels. These channels is a virtual connection inside the “real” TCP connection, and it’s over the channel that you issue AMQP commands.

As each thread spins up, it creates a channel on the existing connection and gets its own private communication path to broker without any additional load on your operating system’s TCP stack.

enter image description here

As a result, you can create a channel hundreds or thousands of times a second without your operating system seeing so much as a blip. There’s no limit to how many AMQP channels you can have on one TCP connection. Think of it like a bundle of fiber optic cable.

Source book: RabbitMq in Action

like image 38
Farhad Jabiyev Avatar answered Oct 09 '22 10:10

Farhad Jabiyev