I'm a bit hesitant about this because I think there are already at
least 3 different ways to handle similar scenarios.

 1. Using listener and avoid calling receive directly
 2. Use multi-topic consumer, so there's a single `Consumer` instance exposed
 3. Use `consumer.receive(0, TimeUnit.SECONDS)` to probe for message


--
Matteo Merli
<matteo.me...@gmail.com>

On Mon, Oct 25, 2021 at 7:34 PM ZhangJian He <shoot...@gmail.com> wrote:
>
> I think it's better to add the method to Consumer interface instead of let
> user casting it to `ConsumerBase`.
> `peek` is most complexly,  for the reason, I can use the `peek` object to
> ack、negative ack, but when to remove from the `BlockingQueue`?
> IMHO, people use this api are just to judge if has the message, otherwise,
> they can just use `receive(0,TimeUnit)
>
> JiangHaiting <jianghait...@foxmail.com> 于2021年10月26日周二 上午10:19写道:
>
> > Can this method
> > "org.apache.pulsar.client.impl.ConsumerBase#getTotalIncomingMessages" do
> > the trick? Though you have to change the type to ConsumerBase.
> >
> >
> > And maybe `peek` is more suitable and useful to add to the Consumer
> > interface?
> >
> >
> >
> >
> >
> >
> > ------------------&nbsp;Original&nbsp;------------------
> > From:
> >                                                   "dev"
> >                                                                 <
> > shoot...@gmail.com&gt;;
> > Date:&nbsp;Mon, Oct 25, 2021 07:24 PM
> > To:&nbsp;"dev"<dev@pulsar.apache.org&gt;;
> >
> > Subject:&nbsp;[DISCUSSION] PIP-108: Add method to help user judge if
> > consumer queue has message
> >
> >
> >
> > https://github.com/apache/pulsar/issues/12479
> >
> > --- Pasted here for quoting convenience ---
> >
> > ## Motivation
> > Currently, I have an application that manages ten thousand of consumers,
> > and a logic to schedule consumers's receive. It would be helpful to know if
> > one of the consumers have message to recive.
> >
> > ## Goal
> > To make `Consumer` can judge if there are unreceiving messages
> >
> > ## API Changes
> >
> > Add `hasMessageInReceiverQueue` on the `Consumer` interface.
> >
> > ## Implementation
> >
> > For `ZeroQueueConsumerImpl` return false, Others, judge the
> > `receiveQueueSize` greater than zero.
> >
> >
> > ## Reject Alternatives
> >
> > No alternatives yet.
> >
> >
> >
> >
> > ---
> > Thanks,
> > Haiting Jiang (Github: Jason918)

Reply via email to