I am using reactor with MongoDB and when saving to Mongo I get the following exception when using OnErrorContinue
org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context
However, the data has been saved correctly in MongoDB. It seems that already handled Exceptions are still being catch by onErrorContinue.
I found the following link describing that behaviour.
https://github.com/spring-projects/spring-data-r2dbc/issues/211
My question is, what is the semactic of onErrorContinue? Should it received already handled exceptions? Is it a bug? I could not find any description of onErrorContinue on the documentation.
Already handled Exception should not be handled by onErrorContinue
Actually onErrorContinue is getting already handled Exceptions.
mongoRepository
.save(data)
.onErrorContinue { e, _ -> logger.warn("Error saving data to repository: $e") }
Then code above prints the following error:
org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context
Although, the data is being saved in MongoDB.
netty, ...):javar -version): 1.8uname -a): Linux Ubuntu 18I'm having same issue here
@mp911de does that ring a bell? In particular the data being visible in mongo despite the apparent transaction error ?
@ovu what happens if you DON'T use onErrorContinue? eg. replace it with a .log()?
By the way, this operatore is one that you should refrain from using if you don't fully understand the implications of it.
NoTransactionInContextException isn鈥檛 an error, it鈥檚 the signal Spring's transaction infrastructure uses to signal that no transaction is in progress.
mmh this makes me fear that onErrorContinue could impair some sources, like the mongo reactive repository in the present case, because it propagates through Context to the whole upstream chain 馃う
@ovu what happens if you DON'T use
onErrorContinue? eg. replace it with a.log()?
can you answer the question? have you tried using onErrorReturn or onErrorResume rather than onErrorContinue ?
@simonbasle Sorry for the delay.
Changing the code to use onErrorReturn or onErrorResume the code worked as it should be. The issue is only related to onErrorContinue together with the MongoDB integration. Only onErrorContinue throws the error NoTransactionInContextException even the data was saved in Mongo. It looks like a bug in the MongoDb integration.
Some work will be done around #2184. in the meantime, onErrorContinue is probably not the best tool for you to use right now (double-edged sword) => please favor the other standard error handling options.
Most helpful comment
I'm having same issue here