momo-jun commented on code in PR #514: URL: https://github.com/apache/pulsar-site/pull/514#discussion_r1165025588
########## docs/concepts-messaging.md: ########## @@ -515,16 +515,64 @@ Exclusive is the default subscription type. #### Failover -In the *Failover* type, multiple consumers can attach to the same subscription. A master consumer is picked for a non-partitioned topic or each partition of a partitioned topic and receives messages. When the master consumer disconnects, all (non-acknowledged and subsequent) messages are delivered to the next consumer in line. +In the *Failover* type, multiple consumers can attach to the same subscription. -* For partitioned topics, the broker will sort consumers by priority level and lexicographical order of consumer name. The broker will try to evenly assign partitions to consumers with the highest priority level. -* For non-partitioned topics, the broker will pick consumers in the order they subscribe to the non-partitioned topics. +A master consumer is picked for a non-partitioned topic or each partition of a partitioned topic and receives messages. -For example, a partitioned topic has 3 partitions, and 15 consumers. Each partition will have 1 active consumer and 4 stand-by consumers. +When the master consumer disconnects, all (non-acknowledged and subsequent) messages are delivered to the next consumer in line. -In the diagram below, **Consumer A** is the master consumer while **Consumer B** would be the next consumer in line to receive messages if **Consumer A** is disconnected. +##### Failover | Partitioned topics - +For partitioned topics, the broker sorts consumers by priority level and lexicographical order of consumer name. + +The broker tries to evenly assign partitions to consumers with the highest priority level. + +A consumer is selected by running a module operation `mod (partition index, consumer index)`. + +- If the number of a partitioned topic is **less** than the number of consumers: + + For example, in the diagram below, this partitioned topic has 2 partitions and there are 4 consumers. + + Each partition has 1 active consumer and 1 stand-by consumer. + + - For p0, Consumer A is the master consumer, while Consumer B would be the next consumer in line to receive messages if Consumer A is disconnected. + + - For p1, Consumer C is the master consumer, while Consumer D would be the next consumer in line to receive messages if Consumer C is disconnected. + +  + +- If the number of a partitioned topic is **greater** than the number of consumers: Review Comment: Oh, I missed the following statement but paid attention to the two IF conditions. Maybe adding a descriptive example starting with `-` would be good enough to show all the three conditions. > The broker tries to evenly assign partitions to consumers with the highest priority level. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
