简体   繁体   中英

What is the best way to parallelize Pulsar consumer workload?

I want to use Pulsar as a message queue using shared consumers and the Java client. For the moment being, there are no strict ordering requirements, and also no partitions. The tasks triggered by the messages usually take up to 2 seconds. Is there any clear preference which of the following two methods of splitting the work between threads in a single application instance should be picked:

  1. 1 consumer with receive queue size 100 and 10 threads in a threadpool calling consumer.receive() in a loop.
  2. 10 consumers with receive queue size 10 each, using the MessageListener interface and running the task inside the original MessageListener.receive() call.

The best answer should be - just measure it:) Saying that, the first approach should be more efficient since no broker communication overhead is involved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM