I think the key point is whether we should consider a regex consumer without any subscribed topics as a valid consumer.
> For example, when users create a regex consumer that subscribes to topics ("tp0", "tp1", ..., "tpN") and seek to the earliest, they might expect to consume messages from these topics. However, if they used a wrong regex like "tp*" (it should be "tp.*), then they might find no messages are available even if they're sure there is at least one non-empty topic whose name starts at "tp" from the topic stats. Actually, for this example, if we treat a consumer without any subscribed topics as an invalid consumer, we should throw an expcetion when the regex consumer first subscribes, instead of waiting until the seek to inform the user that there are no topics. Currently, however, no exception is thrown when a regex consumer subscribes without any topics. I prefer not to break the current behavior as it's probably not a bug. Alternatively, we could introduce a new option for users who do not want to seek on the consumer without any topics. BR, Zike Yang On Thu, May 30, 2024 at 1:10 AM Yunze Xu <x...@apache.org> wrote: > > For example, when users create a regex consumer that subscribes to > topics ("tp0", "tp1", ..., "tpN") and seek to the earliest, they might > expect to consume messages from these topics. However, if they used a > wrong regex like "tp*" (it should be "tp.*), then they might find no > messages are available even if they're sure there is at least one > non-empty topic whose name starts at "tp" from the topic stats. > > Thanks, > Yunze > > On Wed, May 29, 2024 at 7:32 PM Enrico Olivelli <eolive...@gmail.com> wrote: > > > > Il giorno mer 29 mag 2024 alle ore 11:10 Baodi Shi <ba...@apache.org> ha > > scritto: > > > > > +1 > > > > > > > > > Thanks, > > > Baodi Shi > > > > > > > > > On May 29, 2024 at 14:50:12, Yunze Xu <x...@apache.org> wrote: > > > > > > > Hi community, > > > > > > > > Recently I found the behavior of seeking a multi-topics consumer is > > > > intuitive. If there are no internal consumers, the `seek` call will > > > > just succeed silently. > > > > > > > > > > > > > > > If a consumer subscribes with a regex and no topics are found, users > > > > might think the seek operation succeeds while no topics are sought. > > > > > > > > I suggest throwing an exception in this case to notify users that the > > > > consumer to seek is a multi-topics consumer that contains no topics. > > > > It's a breaking change so I'd like to hear more voices in the mail > > > > > > > What happens if it subscribed to a regex which "currently" doesn't not > > match any topics ? > > Maybe this is intentional in the application design as maybe you have > > dynamic topics > > > > Giving an error or failing silently doesn't fix the problem. > > If the application is sure that you must have at least N topics then we > > should make this configurable somewhere. > > The difference between "zero topics" or "one topic" is very small, if your > > application expects to subscribe to 100 topics. > > > > > > Enrico > > > > > > > > > > list. > > > > > > > > For now, I report an error for the C++ client [1], which might also > > > > affect the Python and Node.js clients. But the behavior of the Java > > > > client does not change. > > > > > > > > [1] https://github.com/apache/pulsar-client-cpp/pull/426 > > > > > > > > Thanks, > > > > Yunze > > > > > > >