-
I'm developing an app using Micronaut, Kotlin (with coroutines) and R2DBC (here's the code) and after upgrading Micronaut version (to v4) I'm not able to make integrated tests work due to reactive transaction context. good news is that this error is happening only in test environment. in my local environment it is working perfectly. |
Beta Was this translation helpful? Give feedback.
Answered by
dstepanov
Aug 11, 2023
Replies: 1 comment 3 replies
-
Avoid combining coroutines and R2DBC. In the future, we should have some Coroutine TX operations to avoid R2dbc code in Kotlin. For now, you can create: @Singleton
open class KotlinTransactional {
@Transactional
open suspend fun <T> inTx(tx: suspend () -> T): T {
return tx.invoke()
}
} And use it: beforeEach {
runBlocking { // Might not be needed
kotlinTransactional.inTx {
employeeDataAccessPort.deleteAll()
}
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
lucasgust
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Avoid combining coroutines and R2DBC. In the future, we should have some Coroutine TX operations to avoid R2dbc code in Kotlin.
For now, you can create:
And use it:
beforeEach { runBlocking { // Might not be needed kotlinTransactional.inTx { employeeDataAccessPort.deleteAll() } } }