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