Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring rabbitMQ - transactions and transaction manager

Iv'e heard all over the internet that rabbitMQ does not support transactions.

Now, that said, spring framework provides us with a rabbit transaction manager:

here is a snippet of its definition:

<bean id="rabbitTransactionManager"
    class="org.springframework.amqp.rabbit.transaction.RabbitTransactionManager">
    <property name="connectionFactory" ref="connectionFactory" />
</bean>

So my question is:

1) does using @transactional annotation on a method with the transaction manager actually guarantees a transaction effect? 2) how does spring managed to achieve transaction while rabbit is non transnational ?

like image 397
Urbanleg Avatar asked Nov 14 '25 23:11

Urbanleg


1 Answers

Rabbit does support local transactions. For example in a transaction if something happens in you consumer, and the received message cannot be processed the message is sent back to broker and is not consumed.

Different from other brokers (such as most of the JMS based ones) is that Rabbit does not support distributed transactions (XA transcations). This means you cannot have the same transaction when sending a message over Rabbit and persisting some data in the database.

like image 66
Random42 Avatar answered Nov 17 '25 13:11

Random42



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!