I have read Akka streams materialization concept, and understand stream materialization is:
the process of taking a stream description (the graph) and allocating all the necessary resources it needs in order to run.
I followed one example to build my akka stream using mapMaterializedValue to send message to queue. The purpose of the code is to push the message to queue after the stream blue print have build and the code is working but I do not really understand what does mapMaterrializaedValue do in the code:
Promise<SourceQueueWithComplete<String>> promise = new Promise.DefaultPromise<>();
Source<String, SourceQueueWithComplete<String>> s = Source
.queue(100, OverflowStrategy.fail())
.mapMaterializaedValue(queue -> {
promise.trySuccess(queue);
});
source.toMat(Sink.foreach(x -> System.out.println(x)), Keep.left()).run(materIalizer);
promise.<SourceQueueWithComplete<String>>future().map(mapMapperFunction(), actorSystem.dispatcher());