3. Our solution implements the distributed flow control ability at client side, so we don't use the listener way. 2. Per customer per consumer in different tenants and namespace, and the `flow-control` need(Some of our customer's machines can't work on high traffic), So `Multi-topic` can't use. 1. We want to use this api to judge if there's messages to receive, like that pseudo code if (consumer.hasMessage()) { .submit(() -> { consumer.pollMessagesAccordingToTheDistributedFlowControl() }) }
Matteo Merli <matteo.me...@gmail.com> 于2021年10月26日周二 下午12:15写道: > 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? > > > > > > > > > > > > > > > > > > > > > ------------------ Original ------------------ > > > From: > > > "dev" > > > < > > > shoot...@gmail.com>; > > > Date: Mon, Oct 25, 2021 07:24 PM > > > To: "dev"<dev@pulsar.apache.org>; > > > > > > Subject: [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) >