Interesting things happen inside the webflux package. However, my journey in the source didn't solve the following question.
Let's say I have the following mono (or flux):
Mono hello = Mono.empty()
.subscriberContext(ctx -> ctx.put("message", "hello"));
I use similar construct within a webfilter to enrich the pipeline with tenant and user data. Then in a controller a construct like this is used:
Mono world = Mono.subscriberContext()
.map(ctx -> (String)ctx.get("message"));
The context of the hello mono is filled in the world mono. I tried to figure out how this is done, also for unit testing purposes.
In the end it remains a riddle. I tried to do this with the regular methods available on both mono/flux objects but I don't succeed in making the hello context available to the world mono. How can you fuse fluxes and monos and passing the context along the way to the upstream operators?