Akka Steam Graphs — Dynamic Parallel Streams, Example 3
1 min readApr 2, 2019
Background
Please read the link below for the first example and a background
Second Example:
Akka Stream Graphs
From Akka website:
Considering linear Flows to be like roads, we can picture graph operations as junctions: multiple flows being connected at a single point.
Read up on Akka Stream Graphs here:
Second Graph code example from Akka Site
Understanding the example
Code Modifications
- Added a materializer to run the Graph
final ActorSystem system = ActorSystem.create("QuickStart");
final Materializer materializer = ActorMaterializer.create(system);
- Changed source to print the result
g.run(materializer).forEach(s -> s.thenAccept(System.out::println));
- Add a terminate to stop the run
system.terminate();
Modified Code
Understanding
- Our Source is has five numbers “N” Strings
- Then we have a broadcast with N dynamic paths, based on the number of filters
- We have N flows through the N filters
- We print on out values
Code Output
ax
bx
cx
Conclusion
Streams are a powerful way to develop modern reactive applications.
Akka Graphs add another powerful layer to stream processing.
What is your opinion ? Please do comment in section below.