[英]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.我想使用 Pulsar 作为消息队列,使用共享消费者和 Java 客户端。 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.
消息触发的任务通常最多需要 2 秒。 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:
是否有任何明确的偏好应该选择以下两种在单个应用程序实例中的线程之间拆分工作的方法中的哪一种:
consumer.receive()
in a loop. consumer.receive()
的消费者。MessageListener.receive()
call. MessageListener.receive()
调用中运行任务。 The best answer should be - just measure it:) Saying that, the first approach should be more efficient since no broker communication overhead is involved.最好的答案应该是 - 只是衡量它:) 话虽如此,第一种方法应该更有效,因为不涉及代理通信开销。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.