visortelle commented on issue #22529:
URL: https://github.com/apache/pulsar/issues/22529#issuecomment-2067943011
Interesting.
My observation is that after you create a pattern consumer, for
non-persistent topics it doesn't "immediately" create the underlying
subscription and consumers if there are no connected producers at this moment.
But it will eventually be created after a short time.
TIP: you can display the list of the underlying consumers by casting your
consumer to `PatternMultiTopicsConsumerImpl` and calling the `.getConsumers()`
method.
```java
List<ConsumerImpl<byte[]>> consumers =
((PatternMultiTopicsConsumerImpl<byte[]>)
allTopicsConsumer).getConsumers();
for (ConsumerImpl<byte[]> consumer : consumers) {
System.out.println("consumer: " + consumer.getTopic());
}
```
If you modify your code to send a lot of messages asynchronously, you'll
start to receive them after a short time.
```java
for (int i = 0; i < 100000; i++) {
producer.sendAsync("=========from topic
non-persistent://tenant-1/name/topic-1 " + i);
}
```
```
...
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10732
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10733
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10734
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10735
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10736
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10737
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10738
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10739
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10740
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10741
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10742
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10743
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10744
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10745
Received message from topic non-persistent://tenant-1/name/topic-1:
=========from topic non-persistent://tenant-1/name/topic-1 10746
```
I don't know if it can qualify as a bug. cc @lhotari
I wouldn't rely on non-persistent topics if losing a non-significant amount
of messages could affect my application.
--
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]