We are trying to decorate asynchronous Hazelcast threads with our current log (MDC) context.
Typically a Hazelcast thread might look like: hz._hzInstance_1_xxx.cached.thread-1]
Is this possible?
We would like to do something such as the following which is how we can achieve decoration of threads in a ThreadPoolTaskExecutor in Spring:
private static class MdcTaskDecorator implements TaskDecorator {
@Override
public Runnable decorate(Runnable runnable) {
Map<String, String> contextMap = MDC.getCopyOfContextMap();
return () -> {
try {
if (contextMap != null) {
MDC.setContextMap(contextMap);
}
runnable.run();
} finally {
MDC.clear();
}
};
}
}