liangyepianzhou commented on code in PR #875: URL: https://github.com/apache/pulsar-site/pull/875#discussion_r1554556263
########## docs/tutorials-redeliver-messages.md: ########## @@ -0,0 +1,236 @@ +--- +Id: tutorials-redeliver-messages +title: Consume best practice +sidebar_label: "Consume best practice" +description: Learn how to consume messages and redeliver unacknowledged messages in Pulsar. +--- + +# Consume Best Practice + +## Background Knowledge + +### Subscription Types + +Pulsar is a distributed message system where messages can be sent to topics by producers and consumed by consumers. +Consumers can subscribe to the topics in four ways (subscription types): + +* **Exclusive** +* **Failover** +* **Shared** +* **Key-shared** + +The messages are consumed in order for a single partition in Exclusive and Failover modes and out of order for Shared and +Key-shared mode. The main difference between Exclusive and Failover is that in Exclusive mode, the consumer is exclusive +to the entire topic, while in Failover mode, the consumer is exclusive to only one partition. Failover mode allows backup +consumer connections that are not consumed. The main difference between Shared and Key-shared is whether their dispatch Review Comment: And there are many selector implementations of the selector for the key-shared mode. For the `ConsistentHashingStickyKeyConsumerSelector`, it could be like the following: ```java public Consumer select(int hash) { rwLock.readLock().lock(); try { if (hashRing.isEmpty()) { return null; } List<Consumer> consumerList; Map.Entry<Integer, List<Consumer>> ceilingEntry = hashRing.ceilingEntry(hash); if (ceilingEntry != null) { consumerList = ceilingEntry.getValue(); } else { consumerList = hashRing.firstEntry().getValue(); } return consumerList.get(hash % consumerList.size()); } finally { rwLock.readLock().unlock(); } } ``` -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org