Hi, I'm looking into start using coroutines in mic...
# micronaut
b
Hi, I'm looking into start using coroutines in micronaut, hopefully by just adding
suspend
on the controllers and let micronaut handle most of the wiring. But my team has made me aware of a potential issue that using coroutines and
@Transactional
doesn't work straight out of the box. And I can't find a resolute documentation on any limitations or caveats on it. Does anyone have a good answer/documentation on the subject?
l
I got a bit curious about that issue because it seems to work on my side project (I didn't notice any issue) and found some fixes related to it, which made me think that it was already resolved... - https://github.com/micronaut-projects/micronaut-data/issues/1271 - https://github.com/micronaut-projects/micronaut-data/issues/1216 Anyway, can you share details about that problem? I've never experienced that kind of issue, even in some of my oldest projects using Micronaut, but I also not sure if I, in fact, have used coroutines+transactional on them...
b
Thanks for the reply, and sorry for the late response (having the flu). I think the issue might be a combination of us using the
CrudRepository
and coroutines. That we had to change all our repositories to
CoroutineCrudRepository
and that was a bigger job than they wanted at the time, so now they "learned" to not use suspend because it might be a problem instead. Do you know if there's any documentation on the subject?
Seems to also be the
JpaSpecificationExecutor
that needs to be a
CoroutineJpaSpecificationExecutor
. I'll try to refactor our code in a few weeks.
l
My use case is too simple, may it be the reason I didn't notice any issue. In fact, I was using the
CoroutineCrudRepository
on the repository. I took a look at the doc, and found a reference here: https://micronaut-projects.github.io/micronaut-data/latest/guide/#otherRepositoryVariations