-
I'm using
but it didn't work. In my case, I need a "fresh" context (at least tx context) to get current "versions" from the database (as the entites may be changed by other processes while "retrying" in my use-case. Here is a simplified (and kind of useless) example:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
/cc @FroMage (context-propagation), @Ladicek (fault-tolerance), @manovotn (context-propagation) |
Beta Was this translation helpful? Give feedback.
-
I don't think this has anything to do with context propagation and everything to do with interceptor priorities. It turns out that @Retry(maxRetries = 3, delay = 5000)
void checkAndDoFoo(Long id) {
checkAndDoFoo0(id);
}
@Transactional
void checkAndDoFoo0(Long id) {
// how to get a "current/fresh" Foo?
Foo f = Foo.findById(id);
if (f.status != Status.OPEN) {
throw new RuntimeException("Still not open");
}
// do something with the "OPEN" foo...
} Remember that the |
Beta Was this translation helpful? Give feedback.
I don't think this has anything to do with context propagation and everything to do with interceptor priorities. It turns out that
@Transactional
has lower priority than@Retry
, so all retries happen in the same transaction. You can change that either by configuration, or by cleverly splitting the method into 2:Remember that the
checkAndDoFoo0()
…