Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I publish or subscribe to a materialized Akka Stream flow graph?

I'm playing around with Akka Stream and I'm trying to figure out its flexibility after materialization.

One way to do so is to use the low level reactive streams API: http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M3/#akka.stream.scaladsl.PublisherSource

However, you need to define these points to publish or subscribe to. Is there a way to publish or subscribe to an arbitrary materialized flow graph node? This should be possible, since a materialized flow graph is nothing more than a collection of actors.

For example: First, deploy flow graph 1: A ~> B ~> C

Then, deploy flow graph 2 and 3: D ~> B B ~> E

like image 565
Ruurtjan Pul Avatar asked Feb 17 '15 13:02

Ruurtjan Pul


People also ask

What is materialized value in Akka stream?

The Akka Streams library calls them materialized values. That's because, when you plug components together, you have an inert graph, but when you call the run method, the graph comes alive, or is materialized. The Jedi value returned by materializing a graph is called a materialized value.

Can you describe what are 3 main components of Akka streams?

Akka Streams is a library to process and transfer a sequence of elements using bounded buffer space. This latter property is what we refer to as boundedness and it is the defining feature of Akka Streams. Akka streams consist of three major components in it – Source, Flow and Sink.

Is Akka streams distributed?

Unlike heavier “streaming data processing” frameworks, Akka Streams are neither “deployed” nor automatically distributed.

What is actor Materializer?

Actor Materializer Lifecycle. The Materializer is a component that is responsible for turning the stream blueprint into a running stream and emitting the “materialized value”.


1 Answers

It is not possible to completely dynamically change structures of stream processing pipelines. We do foresee certain kinds of dynamic processing stages (like an "fanout to workers which may come and go"), but in general streams and stream processing pipelines should have a defined layout before materialisation. This also makes sense because of the back-pressure mechanisms employed in akka-streams and reactive-streams in general – it has to be carefully managed internally, and allowing arbitrary interactions is just not something this streaming model is designed for.

If you want arbitrary interactions, Actors should suit you better. If you want to have a processing element that can take external signals to steer the processing pipeline, it would be a special element inside that materialised pipeline designed to take in these signals, not just any element.


Since I published this post we added some dynamic features, which may be of interest to people who land on this site, most notably the MergeHub and the BroadcastHub

Please note that as ow writing the stable version of Akka Streams is 2.4.16.

like image 133
Konrad 'ktoso' Malawski Avatar answered Sep 21 '22 19:09

Konrad 'ktoso' Malawski