简体   繁体   中英

Send multiple jms messages in a single transaction

Instead of sending single message in a transaction:

jmsTemplate.convertAndSend(message);

How can I send multiple jms messages in a single transaction?

Is there an example I can loot at?

Start the transaction before calling the template

@Transactional
public void doSends() {
    template.convertAndSend(...)
    ...
    template.convertAndSend(...)
}

The transaction commits when the method exits. See the Spring documentation about transactions.

Or, use one the of the template's execute() methods and do the sends in the callback.

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