Akka is a toolkit for building reactive, distributed, and fault-tolerant applications on the JVM. It provides tools such as actors, streams, and clustering to build microservice systems and reactive applications. Akka was developed by Lightbend as an implementation of the actor model and supports building microservices, event-driven architectures, and real-time data applications in a scalable and resilient manner.
2. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing
3. Akka History
Akka - Initially developed by Jonas Bonér in 2009
First public release 2009
Inspired by Carl Hewitt’s early 70’s work
and the
Erlang runtime system
A distributed, highly concurrent, and event driven
implementation of the Actor Model
on the JVM - Java & Scala
4. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing
19. Actors
Actor Model
Failure is NOT unexpected or unwanted.
It’s just a fact of life.
Failure handing is an architectural feature
not an afterthought.
34. Actors
Summary
• Actors are message driven, stateful building blocks
• Messages are passed asynchronously
• Actors may create other actors
• Actors form supervision hierarchies
• Actors are lightweight and do not hold threads
35. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing
41. Streams
Akka Streams
import GraphDSL.Implicits._
RunnableGraph.fromGraph(GraphDSL.create() { implicit builder =>
val A: Outlet[Int] = builder.add(Source.single(0)).out
val B: UniformFanOutShape[Int, Int] = builder.add(Broadcast[Int](2))
val C: UniformFanInShape[Int, Int] = builder.add(Merge[Int](2))
val D: FlowShape[Int, Int] = builder.add(Flow[Int].map(_ + 1))
val E: UniformFanOutShape[Int, Int] = builder.add(Balance[Int](2))
val F: UniformFanInShape[Int, Int] = builder.add(Merge[Int](2))
val G: Inlet[Any] = builder.add(Sink.foreach(println)).in
C <~ F
A ~> B ~> C ~> F
B ~> D ~> E ~> F
E ~> G
ClosedShape
})
42. Streams
Akka Streams
RunnableGraph.fromGraph(
GraphDSL.create(builder -> {
final Outlet<Integer> A = builder.add(Source.single(0)).out();
final UniformFanOutShape<Integer, Integer> B = builder.add(Broadcast.create(2));
final UniformFanInShape<Integer, Integer> C = builder.add(Merge.create(2));
final FlowShape<Integer, Integer> D =
builder.add(Flow.of(Integer.class).map(i -> i + 1));
final UniformFanOutShape<Integer, Integer> E = builder.add(Balance.create(2));
final UniformFanInShape<Integer, Integer> F = builder.add(Merge.create(2));
final Inlet<Integer> G = builder.add(Sink.<Integer> foreach(System.out::println)).in();
builder.from(F).toFanIn(C);
builder.from(A).viaFanOut(B).viaFanIn(C).toFanIn(F);
builder.from(B).via(D).viaFanOut(E).toFanIn(F);
builder.from(E).toInlet(G);
return ClosedShape.getInstance();
}));
46. Streams
Alpakka
// Read huge file with Wikipedia content
Source<WikipediaEntry,
CompletionStage<IOResult>> wikipediaEntries =
FileIO.fromPath(Paths.get("/tmp", "wiki"))
.via(parseWikiEntries());
// Enrich the data by fetching matching image from a
// web service with HTTP
Source<RichWikipediaEntry,
CompletionStage<IOResult>> enrichedData = wikipediaEntries
.via(enrichWithImageData);
// Store content in Kafka
// and corresponding image in AWS S3
enrichedData
.alsoTo(s3ImageStorage())
.to(kafkaTopic)
.run(materializer);
47. Streams
Summary
• Akka Streams is a Reactive Streams implementation
• Flow control of data via demand based back-pressure
• Provides a rich set of flow processing transformations
48. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing
80. Cluster Features
Summary
• Groups of collaborating actors abstract functionality
• Cluster aware actors react to cluster state changes
• Use out-of-the-box features or create custom features
81. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing
100. Reactive Systems
Summary
Akka is a toolkit for building highly concurrent,
distributed, and resilient message-driven applications
for Java and Scala
101. Reactive Systems Toolkit - Akka
• Microservice Systems
• Clusters within clusters
• System Orchestration
Clustering
Streams
Actors
Cluster Features
• Reactive Services
• Akka & Play Services
• Lagom Microservices
• Membership
• Sharding
• Event Sourcing & CQRS
• Publish & Subscribe
• Distributed Data
• Reactive Streams
• Akka Streams
• Alpakka
• Actor Model
• Supervision
• Routing