RabbitMQ vs Kafka Part 1 - Two Different Takes on Messaging

2019/2/28 posted in  MQ

原文地址 https://jack-vanlightly.com/blog/2017/12/4/rabbitmq-vs-kafka-part-1-messaging-topologies

In this part we'll explore what RabbitMQ and Apache Kafka are and their approach to messaging. Each technology has made very different decisions regarding every aspect of their design, each with strengths and weaknesses. We'll not come to any strong conclusions in this part, instead think of this as a primer on the technologies so we can dive deeper in subsequent parts of the series.

RabbitMQ

RabbitMQ is a distributed message queue system. Distributed because it is usually run as a cluster of nodes where queues are spread across the nodes and optionally replicated for fault tolerance and high availability. It natively implements AMQP 0.9.1 and offers other protocols such as STOMP, MQTT and HTTP via plug-ins.

RabbitMQ takes both a classic and a novel take on messaging. Classic in the sense that it is oriented around message queues, and novel in its highly flexible routing capability. It is this routing capability that is its killer feature. Building a fast, scalable, reliable distributed messaging system is an achievement in itself, but the message routing functionality is what makes it truly stand out among the myriad of messaging technologies out there.

Exchanges and Queues

The super simplified overview:

  • Publishers send messages to exchanges

  • Exchanges route messages to queues and other exchanges

  • RabbitMQ sends acknowledgements to publishers on message receipt

  • Consumers maintain persistent TCP connections with RabbitMQ and declare which queue(s) they consume

  • RabbitMQ pushes messages to consumers

  • Consumers send acknowledgements of success/failure

  • Messages are removed from queues once consumed successfully

Hidden in that list are a huge number of decisions that developers and admins should take to get the delivery guarantees they want, performance characterstics etc, all of which we'll cover in later sections of this series.

Let's take a look at a single publisher, exchange, queue and consumer: