Let's say I have one ActiveMQ Broker and an undefined numbers of consumers.
Problem: * To process a message, consumers need an external service which is either "DATA1" or "DATA2" (specified in the message) * Each server, "DATA1" and "DATA2", can only handle 20 connections * So at most 20 "DATA1" and 2 "DATA2" messages must be dispatched at any time * Because of priorization, the messages must be enqueued in the same queue How can this be solved? As long as I was using message pulling (prefetch of 0), I was able to do this by using a BrokerPlugin that, on messagePull, achieved this by using semaphores and selectors. If the limits were reached, the pull returned null. However, due to performance issues I had to set prefetch to 1 and use push instead. Therefore, my messagePull hack no longer works (it's never called). So far I'm considering implementing a custom Cursor but I was wondering if someone knows a better solution. I also posted this on StackOverflow <https://stackoverflow.com/questions/65738699/activemq-how-do-i-limit-the-number-of-messages-being-dispatched> .