-
Enhancement
-
Resolution: Duplicate
-
Major
-
None
-
None
-
None
When inside an LRA context, using a ManagedExecutor to submit work that does REST requests (using a MP RestClient), will result in requests that do not contain the LRA ID header.
This is caused by the fact that there is no ThreadContextProvider available for propagating the LraId URI to the Current instance.
I would like to propose adding a ThreadContextProvider implementation that contains something like the following:
@Override public ThreadContextSnapshot currentContext(Map<String, String> props) { URI lraId = Current.peek(); if (lraId == null) { return null; } long threadId = Thread.currentThread().threadId(); return () -> { long threadId2 = Thread.currentThread().threadId(); if (threadId != threadId2) { logger.log(FINE, () -> "Pushing " + lraId + " from thread " + threadId + " to " + threadId2); // Executed in new Thread Current.push(lraId); } return () -> { long threadId3 = Thread.currentThread().threadId(); if (threadId != threadId3 && threadId2 == threadId3) { // Executed in new Thread URI oldLra = Current.pop(); logger.log(FINE, () -> "Popping " + oldLra + " obtained from thread " + threadId + " in " + threadId3); } }; }; }
- links to