1
votes

So I am creating concurrent consumers to a topic i.e. multiple listeners. I am configuring them to be durable.

@Bean
    public DefaultMessageListenerContainer listenerContainers() {
        DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
        container.setConnectionFactory(connectionFactory());
        container.setDestinationName(COMMENT_QUEUE);
        container.setPubSubDomain(true);
        container.setSessionTransacted(true);
        container.setConcurrentConsumers(2);
        container.setSubscriptionDurable(true);
        container.setMessageListener(datafileSubscriber);
        container.start();
        return container;
    } 

What I want to know is,
Lets suppose a event came and it is published to all 5 subscribers. One of them processes it, so it doesnt immediately acknowledge until the process is done but remaining 4 immediately acknowledge because they are idle.

Lets suppose a second event came, Now

  1. Is it sent to 4 subscribers and keeps the message in queue for 5th subscriber and sends it to 5th subscriber only after it gives a acknowledgement?

                        OR
    
  2. It doesnt send to any of the message subscribers but waits in the queue until the 5th subscriber also acknowledges and then sends out to all the subscribers at a time?

I am using setsessiontransacted true. What happens now 1 or 2 ? Also I am assuming the broker maintains an internal queue for each concurrent subscriber to understand the flow of messages to that durable subscriber.

Can someone explain how the flow works for the configuration of concurrentconsumer, durable subscription and setsessiontransacted=true?

1

1 Answers

1
votes

Messaging provider will put the event messages into subscriber's subscription queue as and when they are published. It is the subscribers who pull (or receive using listeners) those messages from their subscription queue. So if a subscriber is busy processing an event message, other subscribers are not affected at all, they will continue to receive publications. In fact subscribers won't know the presence of other subscribers.