ActiviteMQ 对于Consumers pending的限制问题

    xiaoxiao2021-03-25  122

    前两天遇到个问题,如果一个queue里堵塞了1000+以上的message,然后启动多个consumers,发现新启动的consumer没有去处理原来堵塞的message,只会处理新进来的message。经过查找发现,原来MQ默认的prefetch limit是1000,也就是说,当一个queue堵塞了1000个message,当有一个consumer运行的时候,这1000个message就会直接分配给这一个consumer,我们可以通过设置这个prefetch limit来控制它,简单的方法就是

    在new stomp的时候传个header进去,比如

    $stomp = new Stomp(tcp://localhost:61613); $headers['activemq.prefetchSize'] = 1; $stomp->subscribe(queuename, $headers);

    相关文档

    http://activemq.apache.org/what-is-the-prefetch-limit-for.html

    http://activemq.apache.org/stomp.html

    转载请注明原文地址: https://ju.6miu.com/read-10514.html

    最新回复(0)