We have an ActiveMQ Classic broker on the default configuration (no specific destination policy configured, and with default KahaDB storage).
Many producers and consumers use the same queue for specific operations. They use a selector to filter what each consumer should read. For example:
String selector = "COMMAND = 'RUN_CALC' AND CATEGORY='CALCULATION'";
QueueReceiver queueReceiver = session.createReceiver(destination, selector);
and producers push messages without any timetolive by setting properties:
MessageProducer producer = session.createProducer(destination);
StringBuilder command = new StringBuilder("RUN_CALC;CATEGORY;CALCULATION;.....");
BytesMessage message = session.createBytesMessage();
message.setStringProperty("COMMAND", "RUN_CALC");
message.setStringProperty("CATEGORY", "CALCULATION");
byte[] byteData = command.toString().getBytes();
message.writeBytes(byteData);
producer.send(message);
Of course this is just a simplification of the code. The system has been running fine since many years with thousands of messages daily consumed with filter and selector by around 40 consumers, but lately we had a scenario where 500 pending messages were present in the queue (non consumed) and all consumers became very slow to receive the messages, like very very slow! I always thought that setStringProperty allowed the broker to properly index messages but it does not seem to work.
I understand best practices are to not have non consumed messages, but it's weird that this low amount of pending messages in the queue made selectors that slow! I tested many different configuration in the ActiveMQ, enabled JMX to monitor, but I didn't find a way to fix this (and our server memory and CPUs are very good so it's not resource issue).