Hey Penghui,
Thanks for the quick reply. So, just confirming, if I set up
ClientBuilder.listenerThreads(8) and initialize 1 consumer and 1 producer,
then all the 8 threads would be used for processing the incoming messages
in a round-robin fashion. Is my understanding correct?

Secondly, I'm trying to understand the producerBuilder.createAsync() &
messageBuilder.sendAsync() concept. I understand that  sendAsync() drops
the message into the producer queue. Does a seperate thread pull the
messages from the queue and then send it to the broker? If so, is there a
way to configure the number of these threads? I'm trying to understand how
best to maintain the producer to get maximum publish throughput?

Would appreciate your feedback.

-- 
Thanks,
Hsekar Rian.

On Wed, Nov 4, 2020 at 7:54 PM PengHui Li <codelipeng...@gmail.com> wrote:

> Hi Hsekar,
>
> > What I would like to know is how multiple incoming messages would be
> handled by this listener? Will each message be handled in a separate thread
> as in the case of JMS listeners? If so, then how can I configure the number
> of threads to use - is it by using the ClientBuilder.listenerThreads()
> property?
>
> Yes, you can use ClientBuilder.listenerThreads() to set the listener
> threads numbers. The client will choose a listener thread for incoming
> messages in round-robin pattern.
>
> > Is there a need to maintain multiple listener objects respective to each
> consumer, when maintaining multiple consumers
>
> It is not necessary, a listener can used by multiple consumers as long as
> they process the messages in the same way
>
> Thanks
>
> Penghui
> On Nov 4, 2020, 6:33 PM +0800, Rakesh Nair <rakesh.n...@6dtech.co.in>,
> wrote:
>
> I'm fairly new to java message listeners and apache pulsar. Assume that
> I've maintained a listener like so,
>
> private MessageListener<byte[]> generateListener() {
>         MessageListener<byte[]> listener = (consumer, respMsg) -> {
>             String respM = new String(respMsg.getValue(), 
> StandardCharsets.UTF_8);
>             logger.info(respM);
>             consumer.acknowledgeAsync(respMsg);
>         };
>         return listener;
>     }
>
> And a Consumer instance like so,
>
> Consumer<byte[]> c = 
> consumerBuilder.messageListener(generateListener()).topic(topicName).subscriptionName("Consumer-"
>  + i).subscribeAsync().get();
>
> What I would like to know is how multiple incoming messages would be
> handled by this listener? Will each message be handled in a separate thread
> as in the case of JMS listeners? If so, then how can I configure the number
> of threads to use - is it by using the ClientBuilder.listenerThreads()
> property?
>
> Is there a need to maintain multiple listener objects respective to each
> consumer, when maintaining multiple consumers i.e, something like this -
>
> consumerBuilder.clone().messageListener(generateListener()).topic(topicName).subscriptionName("Consumer-"
> + i).subscribeAsync() ?
>
> --
> Thanks,
> Hsekar Rian
>
>

Reply via email to