-
Notifications
You must be signed in to change notification settings - Fork 192
Possible bug when using transactions and TransactionalEventListener #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The couchbase transaction does get processed and TransactionalApplicationListenerMethodAdapter.onApplicationEvent() does get triggered with the event having the DataCreated object as the payload. But it falls through to the 'else'.
|
Hi @mikereiche, we saw this same behaviour in our side. I think that the problem is that spring doesn't know that there is an active transaction. With this, spring should be aware that a transaction is running because the event is sent inside a method that is annotated with |
Yes. org.springframework.data.couchbase.core.TransactionSupport.checkForTransactionInThreadLocalStorage() [ the method name is a bit of a misnomer]. Couchbase transactions probably needs to be calling TransactoinSynchronizationManager.bindResource() / unbindResource(). |
This worked with spring boot 2.7.13 and with spring dependency management 1.0.15.RELEASE. I don't know what was the spring-data-couchbase version. |
This issue is still exists. I have "@transactional" block. But It publish a event. But TransacionalEventListener doesnt consume it. I think. Spring doensnt know active transactions because of "CallbackPreferringPlatformTransactionManager" Spring Boot 3.4.4, spring-data-couchbae 5.4.4 |
Can you provide the repo with your project? Or a jar?
There is no listener required for transactions. I don't know what TransactionalEventListener is.
The @transactional annotation applies to methods. The method must be in a class other than the one it is called from, otherwise it will be called directly without being intercepted. org.springframework.data.couchbase.core.TransactionSupport.checkForTransactionInThreadLocalStorage() can be used to determine if the call has been intercepted and is being executed in a transaction. @EnableTransactionManagement also needs to be specified in your implementation of the config class. The base class (AbstractCouchbaseConfiguration) has the other definitions required. The transactionInterceptorCustomizer() sets up the interceptor to use for @transactional code. Here are the transaction tests we run - there are about 500 of them. To run them against a local cb server, you will need to replace src/test/resources/integration.properties with something like this:
|
Hi,
I'm trying to use transactions and TransactionalEventListener, but it seams that spring have some incompatibly issue with this in the version 3.1.1 (I had this working on the version 2.7.13).
When the transaction is committed the TransactionalEventListener isn't been triggered and on the logs I got this entry:
Also if I check my bucket I got some extra documents with binary values:

In the file couchbaseTransactions.zip is possible to check my current approach to get this working.
The text was updated successfully, but these errors were encountered: