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