Technoboy- commented on PR #13960:
URL: https://github.com/apache/pulsar/pull/13960#issuecomment-1121003868
> In addition, this also makes consumer not able to seek to an older
position after topic terminates.
>
> ```java
> try (PulsarClient client =
PulsarClient.builder().serviceUrl("pulsar://localhost:6650").build()) {
> CountDownLatch latch = new CountDownLatch(1);
> Consumer<byte[]> consumer = client.newConsumer()
> .topic("my-topic")
> .subscriptionName("sub")
>
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
> .messageListener(new MessageListener<byte[]>() {
> @Override
> public void received(Consumer<byte[]> consumer,
Message<byte[]> msg) {
> System.out.println("Received " + new
String(msg.getValue()));
> consumer.acknowledgeAsync(msg);
> }
>
> @Override
> public void reachedEndOfTopic(Consumer<byte[]>
consumer) {
> System.out.println("consumer closed");
> latch.countDown();
> }
> })
> .subscribe();
> latch.await();
> try {
> consumer.seek(MessageId.earliest);
> System.out.println("seek done");
> } catch (PulsarClientException e) {
> e.printStackTrace();
> }
> ```
>
> Run the application above, the run following commands.
>
> ```shell
> ./bin/pulsar-client produce -m hello my-topic
> ./bin/pulsar-admin topics terminate my-topic
> ```
>
> Before this patch, the output will be:
>
> ```
> Received hello
> consumer closed
> seek done
> ```
>
> After this patch, the output will be:
>
> ```
> Received hello
> consumer closed
> org.apache.pulsar.client.api.PulsarClientException$AlreadyClosedException:
The consumer d9dc7 was already closed when seeking the subscription sub of the
topic persistent://public/default/my-topic to the message -1:-1:-1
> ```
>
> It's only a case for `seek`. I'm not sure whether the methods added in
future could still fail automatically by this behavior change. Whatever, it
will make users confused.
yes, right. this is a case. even if the topic is terminated, the
subscription can be created.
So I decide to close this patch.
--
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]