How does AMQP overcome the difficulties of using TCP directly?

允我心安 提交于 2020-04-13 08:02:09

问题


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


回答1:


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.




回答2:


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.

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



来源:https://stackoverflow.com/questions/15147576/how-does-amqp-overcome-the-difficulties-of-using-tcp-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!