liangyepianzhou commented on code in PR #875:
URL: https://github.com/apache/pulsar-site/pull/875#discussion_r1554552425


##########
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

Review Comment:
   Yes, it is. For example, there is topic 1 with five partitions; five 
consumers can subscribe to topic 1 in the failover mode, and only one consumer 
can subscribe to topic 1 in the exclusive mode. The add consumer logic just 
like this:
   ```java
                           case Exclusive:
                               if (dispatcher == null || dispatcher.getType() 
!= SubType.Exclusive) {
                                   previousDispatcher = dispatcher;
                                   dispatcher = new 
PersistentDispatcherSingleActiveConsumer(
                                           cursor, SubType.Exclusive, 0, topic, 
this);
                               }
                               break;
   .....
                           case Failover:
                               int partitionIndex = 
TopicName.getPartitionIndex(topicName);
                               if (partitionIndex < 0) {
                                   // For non partition topics, use a negative 
index so
                                   // dispatcher won't sort consumers before 
picking
                                   // an active consumer for the topic.
                                   partitionIndex = -1;
                               }
   
                               if (dispatcher == null || dispatcher.getType() 
!= SubType.Failover) {
                                   previousDispatcher = dispatcher;
                                   dispatcher = new 
PersistentDispatcherSingleActiveConsumer(cursor, SubType.Failover,
                                                   partitionIndex, topic, this);
                               }
                               break;
   ```



-- 
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]

Reply via email to