Reputation: 2605
I have a single instance of ActiveMQ and a producer is pushing data to a queue. Currently, we have a single consumer with concurrency set as 1-5 which was developed using Spring Boot. Now I ran the same Spring Boot application (Consumer) in different ports to scale out the consumers. When I checked the logs, only one consumer is receiving the message and another consumer (which is a replica of the other) is not receiving any messages from that queue.
Please find the consumer code below
public JmsListenerContainerFactory<?> orderEventListenerFactory(ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConcurrency("1-5");
factory.setSessionAcknowledgeMode(javax.jms.Session.CLIENT_ACKNOWLEDGE);
configurer.configure(factory, connectionFactory);
return factory;
}
@JmsListener(destination = "order_queue?consumer.prefetchSize=1", containerFactory = "orderEventListenerFactory")
@Override
public void consumeOrderEvent(String event) {
// Some BL
}
Do I need to configure something on the broker or consumer side so that messages will be consumed in round-robin fashion i.e. basically sharing the load between these two consumers? I tried setting prefetch equals to 1 but still whichever consumer starts first is receiving the messages.
Upvotes: 0
Views: 306