简体   繁体   中英

How spring works for multiple @JmsListener on a single method

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM