1. Can Kafka achieve point-to-point (one-to-one) consumption?

In Kafka, multiple consumers listen to the same topic, and a message comes in. There are two options: many-to-one consumption: all consumers can consume this message. One-to-one consumption: only one consumer can consume this message.

If all consumers belong to the same consumer group, then one consumer can consume the message. If all consumers belong to different groups, then all consumers can consume the message

Partition for Kafka

When Kafka was first used, there was no concept of partitioning, as with traditional MQ middleware, the data in Kafka was fetched directly from the program. It was later discovered that only one consumer (a consumer application deployed on multiple Tomcats) would ever fetch data from Kafka for processing, until the concept of partitioning was introduced.

The answer is no, there is a lot of data on the web, but in general: Kafka partitioning, which is like subdividing a Topic into channels, allows a consumer application to get data from one or more partitions. There are 4 partitions and 1 consumer: this one consumer is responsible for consuming data for the four partitions. There are 4 zones, 2 consumers: each consumer is responsible for 2 zones there are 4 zones, 3 consumers: Consumer 1 is responsible for 1 zone, consumer 2 is responsible for 1 zone, consumer 3 is responsible for 2 zones there are 4 zones, 4 consumers: one person one has 4 zones, 5 or more consumers: There are four customers, one for each of them, and the rest of them are idle. Try to deploy one consumer for one partition.

Note: If there is a specified partition number, it is sent directly to the specified partition. If the partition number is not specified, the hash value of the key will be used to obtain a fixed partition number, and the data will be sent to the same partition. Kafka’s default algorithm is to obtain all working partition numbers and then allocate each data to the obtained partition evenly.