0
votes

I want to make clear out that if I put multiple @jmsListener on a single method, then how it works? If it will work parallel like multiple individual JMS listener? Or it will work sequentially like just one JMS listener?

Like:

    @JmsListener(destination = "queue.name1", containerFactory = "jmsListenerContainerFactory")
    @JmsListener(destination = "queue.name2", containerFactory = "jmsListenerContainerFactory")
    @JmsListener(destination = "queue.name3", containerFactory = "jmsListenerContainerFactory")
    @JmsListener(destination = "queue.name4", containerFactory = "jmsListenerContainerFactory")
    public void receiveQueue(Message message, Session session) throws JMSException {
        //TODO for message queue consuming logic
    }

My question is will spring generate 4 individual JMS listener and work parallel or spring only generate 1 JMS listener and work sequentially for 4 different message queues?

1

1 Answers

1
votes

Each JmsListener annotation will build a JMS listener container, so there will be 4 JMS listeners working in parallel. From the JavaDoc of the JmsListener annotation:

Annotation that marks a method to be the target of a JMS message listener on the specified destination(). The containerFactory() identifies the JmsListenerContainerFactory to use to build the JMS listener container.