Open jmilktea opened 4 years ago
I think, i know what the problem is. You are the subscriber now and you have lost the original subscriber context with the traceId, so you need to take over the original subscriber context eg.:
//123
System.out.println(Thread.currentThread().getId() + ":" + MDC.get("traceId"));
return Mono.subscriberContext()
.doOnNext(context -> Mono.just(1).subscriberContext(context) // here the take over
.map(s -> {
thread1(); // and it works here
return 1;
}).doOnNext(integer -> {
System.out.println(Thread.currentThread().getId() + ":" + MDC.get(CORRELATION_ID_KEY)); // and here!
})
.subscribeOn(SETTLEMENT_SCHEDULER)
.subscribe())
.thenMany(
Flux.just(1).map(s -> {
thread2();
return 1;
}).subscribeOn(SETTLEMENT_SCHEDULER));
Can't get value in different streams
eg: Setting parameters using webfilter