There is a possibility to enrich Reactor's sequence context with some data at subscription time as follows:
Mono.just("Hello")
.flatMap(s -> Mono.deferContextual(ctx -> Mono.just(s + " " + ctx.get(key))))
.contextWrite(ctx -> ctx.put(key, "World"));
However, this "World" here is sort of static data which is know at subscription time.
I'd like to resolve a value from the initial Mono itself and put it into the context, so that downstream operators can access it via context API.
How can I properly do that?
The use case I am working on is following:
- I receive an SQS message from AWS via the async SDK which is resolved to a Reactor's Mono
- A message has a
correlation_idinside which I want to extract and put it into Reactors context to make it visible to all downstream operators.