GitHub user volfco added a comment to the discussion: geo replicated subscribers

@sijie I've gotten a MVP cluster setup between two DCs that are ~40ms apart 
with replication between them.

This is my code (I'm horrible at java):
```java
import org.apache.pulsar.client.api.*;

public class Main {

    public static void main(String[] args) throws Exception {

        if (args.length != 1) {
            System.out.println("Need serviceURL");
            System.exit(1);
        }

        PulsarClient client = PulsarClient.builder()
                .serviceUrl(args[0])
                .build();

        Consumer consumer = client.newConsumer()
                .topic("persistent://development/ns1/test")
                .subscriptionName("consumer")
                .replicateSubscriptionState(true)
                .subscribe();

        System.out.println("starting consumption");
        System.out.println(args[0]);

        while (true) {
            Thread.sleep(100);
            // Wait for a message
            Message msg = consumer.receive();

            try {
                // Do something with the message
                System.out.printf("Message received: %s\n", new 
String(msg.getData()));

                // Acknowledge the message so that it can be deleted by the 
message broker
                consumer.acknowledge(msg);
            } catch (Exception e) {
                // Message failed to process, redeliver later
                consumer.negativeAcknowledge(msg);
            }
        }
    }
}
```

Reading PIP-33, I'm operating under the assumption if I run one consumer 
reading from AUS, that consumer dies, and I start one reading from IAD a few 
seconds later, I shouldn't encounter many duplicate messages.

This is not what I'm seeing. I can start the consumer in AUS, it'll start 
reading. I close it at message 10 and wait a few seconds and start an IAD 
consumer. It will start at the 0 position, and not around 10 like I would 
expect. If I restart the AUS consumer, it will pick up at message 10 and ignore 
any progress the IAD one has made.


It also seems that this feature is almost what I'm looking for. From my 
understanding of PIP-33, I can only run one consumer at a time?

GitHub link: 
https://github.com/apache/pulsar/discussions/18983#discussioncomment-4447448

----
This is an automatically sent email for dev@pulsar.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@pulsar.apache.org

Reply via email to