Spring 4.3 :: Using a TaskDecorator with @Async functionality
This project demonstrates how you can use a
TaskDecorator to transparently copy MDC data from Web threads onto
@Async method threads.
Take a look at the integration tests to see what is expected of the code.
Notice how we expect MDC data to appear with the Web thread logging and with the
@Async thread logging.
com.moelholm.async.demo.MdcFilter: this is where the original MDC data comes from.
src/main/resources/application.yml you find the log configuration that tells Spring Boot to inject an MDC variable next to the logger level.
com.moelholm.async.demo.Application: notice how we tune the @Async behavior in Spring to use a custom
com.moelholm.async.demo.MdcTaskDecorator: this is where we copy MDC data onto the @Async threads.