SlideShare a Scribd company logo
akka streams
Reactive Integrations with
that just work™
Johan Andrén
Konrad Malawski
Johan Andrén
Akka Team
Stockholm Scala User Group
Konrad `ktoso` Malawski
Akka Team,
Reactive Streams TCK,
Persistence, HTTP
Make building powerful concurrent &
distributed applications simple.
Akka is a toolkit and runtime
for building highly concurrent,
distributed, and resilient
message-driven applications
on the JVM
Actors – simple & high performance concurrency
Cluster / Remoting – location transparency, resilience
Cluster tools – and more prepackaged patterns
Streams – back-pressured stream processing
Persistence – Event Sourcing
HTTP – complete, fully async and reactive HTTP Server
Official Kafka, Cassandra, DynamoDB integrations, tons
more in the community
Complete Java & Scala APIs for all features
What’s in the toolkit?
Reactive integrations with Akka Streams
“Stream”
has many meanings
akka streams
Asynchronous back pressured stream processing
Source Sink
Flow
akka streams
Asynchronous back pressured stream processing
Source Sink
(possible)
asynchronous
boundaries
Flow
akka streams
Asynchronous back pressured stream processing
Source Sink
10 msg/s 1 msg/s
OutOfMemoryError!!
Flow
akka streams
Asynchronous back pressured stream processing
Source Sink
10 msg/s 1 msg/s
hand me 3 morehand me 3 more
1 msg/s Flow
akka streams
Not only linear streams
Source
SinkFlow
Source
Sink
Flow
Flow
Reactive Streams
Reactive Streams is an initiative to provide a standard for
asynchronous stream processing with non-blocking back
pressure. This encompasses efforts aimed at runtime
environments as well as network protocols
http://www.reactive-streams.org
Part of JDK 9
java.util.concurrent.Flow
Reactive Streams
RS Library A RS library B
async
boundary
Reactive Streams
RS Library A RS library B
async
boundary
Make building powerful concurrent &
distributed applications simple.
The API
Akka Streams
Complete and awesome
Java and Scala APIs
(Just like everything in Akka)
Akka Streams in 20 seconds:
Source<Integer, NotUsed> source = null;



Flow<Integer, String, NotUsed> flow =

Flow.<Integer>create().map((Integer n) -> n.toString());



Sink<String, CompletionStage<Done>> sink =

Sink.foreach(str -> System.out.println(str));



RunnableGraph<NotUsed> runnable =
source.via(flow).to(sink);



runnable.run(materializer);

Akka Streams in 20 seconds:
CompletionStage<String> firstString =

Source.single(1)

.map(n -> n.toString())

.runWith(Sink.head(), materializer);

Source.single(1).map(i -> i.toString).runWith(Sink.head())
// types: _
Source<Int, NotUsed>
Flow<Int, String, NotUsed>
Sink<String, CompletionStage<String>>
Akka Streams in 20 seconds:
Source.single(1).map(i -> i.toString).runWith(Sink.head())
// types: _
Source<Int, NotUsed>
Flow<Int, String, NotUsed>
Sink<String, CompletionStage<String>>
Akka Streams in 20 seconds:
Materialization
Gears from GeeCON.org,(it’s an awesome conf)
What is “materialization” really?
What is “materialization” really?
What is “materialization” really?
What is “materialization” really?
What is “materialization” really?
Check out the
“Implementing an akka-streams materializer for big data”
talk later today.
AlpakkaA community for Streams connectors
http://blog.akka.io/integrations/2016/08/23/intro-alpakka
Alpakka – a community for Stream connectors
Threading & Concurrency in Akka Streams Explained (part I)
Mastering GraphStages (part I, Introduction)
Akka Streams Integration, codename Alpakka
A gentle introduction to building Sinks and Sources using GraphStage APIs
(Mastering GraphStages, Part II)
Writing Akka Streams Connectors for existing APIs
Flow control at the boundary of Akka Streams and a data provider
Akka Streams Kafka 0.11
Alpakka – a community for Stream connectors
Existing examples:
MQTT
AMQP
Streaming HTTP
Streaming TCP
Streaming FileIO
Cassandra Queries
“Reactive Kafka” (akka-stream-kafka)
S3, SQS & other Amazon APIs
Streaming JSON
Streaming XML
…
Alpakka – a community for Stream connectors
Demo
Alpakka – a community for Stream connectors
Demo
Akka Streams & HTTP
streams
& HTTP
A core feature not obvious to the untrained eye…!
Akka Streams / HTTP
Quiz time!
TCP is a ______ protocol?
A core feature not obvious to the untrained eye…!
Akka Streams / HTTP
Quiz time!
TCP is a STREAMING protocol!
Streaming in Akka HTTP
http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala
“Framed entity streaming”
http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html
HttpServer as a:
Flow[HttpRequest, HttpResponse]
Streaming in Akka HTTP
HttpServer as a:
Flow[HttpRequest, HttpResponse]
HTTP Entity as a:
Source[ByteString, _]
http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala
“Framed entity streaming”
http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html
Streaming in Akka HTTP
HttpServer as a:
Flow[HttpRequest, HttpResponse]
HTTP Entity as a:
Source[ByteString, _]
Websocket connection as a:
Flow[ws.Message, ws.Message]
http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala
“Framed entity streaming”
http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html
It’s turtles buffers all the way down!
xkcd.com
Streaming from Akka HTTP
Streaming from Akka HTTP
Streaming from Akka HTTP
No demand from TCP
=
No demand upstream
=
Source won’t generate tweets
=>
Bounded memory
stream processing!
Demo
Streaming from Akka HTTP (Java)
public static void main(String[] args) {
final ActorSystem system = ActorSystem.create();
final Materializer materializer = ActorMaterializer.create(system);
final Http http = Http.get(system);
final Source<Tweet, NotUsed> tweets = Source.repeat(new Tweet("Hello world"));
final Route tweetsRoute =
path("tweets", () ->
completeWithSource(tweets, Jackson.marshaller(), EntityStreamingSupport.json())
);
final Flow<HttpRequest, HttpResponse, NotUsed> handler =
tweetsRoute.flow(system, materializer);
http.bindAndHandle(handler,
ConnectHttp.toHost("localhost", 8080),
materializer
);
System.out.println("Running at http://localhost:8080");
}
Streaming from Akka HTTP (Java)
public static void main(String[] args) {
final ActorSystem system = ActorSystem.create();
final Materializer materializer = ActorMaterializer.create(system);
final Http http = Http.get(system);
final Source<Tweet, NotUsed> tweets = Source.repeat(new Tweet("Hello world"));
final Route tweetsRoute =
path("tweets", () ->
completeWithSource(tweets, Jackson.marshaller(), EntityStreamingSupport.json())
);
final Flow<HttpRequest, HttpResponse, NotUsed> handler =
tweetsRoute.flow(system, materializer);
http.bindAndHandle(handler,
ConnectHttp.toHost("localhost", 8080),
materializer
);
System.out.println("Running at http://localhost:8080");
}
Streaming from Akka HTTP (Scala)
object Example extends App
with SprayJsonSupport with DefaultJsonProtocol {
import akka.http.scaladsl.server.Directives._
implicit val system = ActorSystem()
implicit val mat = ActorMaterializer()
implicit val jsonRenderingMode = EntityStreamingSupport.json()
implicit val TweetFormat = jsonFormat1(Tweet)
def tweetsStreamRoutes =
path("tweets") {
complete {
Source.repeat(Tweet(""))
}
}
Http().bindAndHandle(tweetsStreamRoutes, "127.0.0.1", 8080)
System.out.println("Running at http://localhost:8080");
}
Next steps for Akka
Completely new Akka Remoting (goal: 700.000+ msg/s (!)),
(it is built using Akka Streams, Aeron).
More integrations for Akka Streams stages, project Alpakka.
Reactive Kafka polishing with SoftwareMill, Krzysiek Ciesielski
Akka Typed progressing again, likely towards 3.0.
Akka HTTP 2.0 Proof of Concept in progress.
Collaboration with Reactive Sockets
Ready to adopt on prod?
Totally, go for it.
Akka <3 contributions
Easy to contribute tickets:
https://github.com/akka/akka/issues?q=is%3Aissue+is%3Aopen+label%3Aeasy-to-contribute
https://github.com/akka/akka/issues?q=is%3Aissue+is%3Aopen+label%3A%22nice-to-have+%28low-prio%29%22
Akka Stream Contrib
https://github.com/akka/akka-stream-contrib
Mailing list:
https://groups.google.com/group/akka-user
Public chat rooms:
http://gitter.im/akka/dev developing Akka
http://gitter.im/akka/akka using Akka
Reactive Platform
Reactive Platform
Reactive Platform
Further reading:
Reactive Streams: reactive-streams.org
Akka documentation: akka.io/docs
Free O’Reilly report – very out soon.
Example Sources:
ktoso/akka-streams-alpakka-talk-demos-2016
Get involved:
sources: github.com/akka/akka
mailing list: akka-user @ google groups
gitter channel: https://gitter.im/akka/akka
Contact:
Konrad ktoso@lightbend.com Malawski
http://kto.so / @ktosopl
Thanks!
Questions?
@apnylle johan.andren@lightbend.com
@ktosopl konrad.malawski@lightbend.com

More Related Content

What's hot (20)

PDF
Not Only Streams for Akademia JLabs
Konrad Malawski
 
PDF
The Need for Async @ ScalaWorld
Konrad Malawski
 
PDF
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Konrad Malawski
 
PDF
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
Konrad Malawski
 
PDF
2014 akka-streams-tokyo-japanese
Konrad Malawski
 
PDF
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Konrad Malawski
 
PDF
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Konrad Malawski
 
PDF
Need for Async: Hot pursuit for scalable applications
Konrad Malawski
 
PDF
Reactive Streams: Handling Data-Flow the Reactive Way
Roland Kuhn
 
PDF
Reactive Stream Processing with Akka Streams
Konrad Malawski
 
PDF
Reactive Streams / Akka Streams - GeeCON Prague 2014
Konrad Malawski
 
PDF
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
Konrad Malawski
 
PDF
The things we don't see – stories of Software, Scala and Akka
Konrad Malawski
 
PDF
Building reactive distributed systems with Akka
Johan Andrén
 
PPTX
Akka Actor presentation
Gene Chang
 
PDF
Journey into Reactive Streams and Akka Streams
Kevin Webber
 
PDF
Streaming all the things with akka streams
Johan Andrén
 
PDF
VJUG24 - Reactive Integrations with Akka Streams
Johan Andrén
 
PDF
Reactive Web-Applications @ LambdaDays
Manuel Bernhardt
 
PDF
System Integration with Akka and Apache Camel
krasserm
 
Not Only Streams for Akademia JLabs
Konrad Malawski
 
The Need for Async @ ScalaWorld
Konrad Malawski
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Konrad Malawski
 
[Tokyo Scala User Group] Akka Streams & Reactive Streams (0.7)
Konrad Malawski
 
2014 akka-streams-tokyo-japanese
Konrad Malawski
 
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Konrad Malawski
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Konrad Malawski
 
Need for Async: Hot pursuit for scalable applications
Konrad Malawski
 
Reactive Streams: Handling Data-Flow the Reactive Way
Roland Kuhn
 
Reactive Stream Processing with Akka Streams
Konrad Malawski
 
Reactive Streams / Akka Streams - GeeCON Prague 2014
Konrad Malawski
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
Konrad Malawski
 
The things we don't see – stories of Software, Scala and Akka
Konrad Malawski
 
Building reactive distributed systems with Akka
Johan Andrén
 
Akka Actor presentation
Gene Chang
 
Journey into Reactive Streams and Akka Streams
Kevin Webber
 
Streaming all the things with akka streams
Johan Andrén
 
VJUG24 - Reactive Integrations with Akka Streams
Johan Andrén
 
Reactive Web-Applications @ LambdaDays
Manuel Bernhardt
 
System Integration with Akka and Apache Camel
krasserm
 

Viewers also liked (8)

PDF
What's The Role Of Machine Learning In Fast Data And Streaming Applications?
Lightbend
 
PDF
Akka streams kafka kinesis
Peter Vandenabeele
 
PDF
Akka Streams - From Zero to Kafka
Mark Harrison
 
PDF
Moving from Big Data to Fast Data? Here's How To Pick The Right Streaming Engine
Lightbend
 
PDF
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Lightbend
 
PDF
Building Streaming And Fast Data Applications With Spark, Mesos, Akka, Cassan...
Lightbend
 
PPTX
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lightbend
 
PDF
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
Lightbend
 
What's The Role Of Machine Learning In Fast Data And Streaming Applications?
Lightbend
 
Akka streams kafka kinesis
Peter Vandenabeele
 
Akka Streams - From Zero to Kafka
Mark Harrison
 
Moving from Big Data to Fast Data? Here's How To Pick The Right Streaming Engine
Lightbend
 
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Lightbend
 
Building Streaming And Fast Data Applications With Spark, Mesos, Akka, Cassan...
Lightbend
 
Lessons Learned From PayPal: Implementing Back-Pressure With Akka Streams And...
Lightbend
 
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
Lightbend
 
Ad

Similar to Reactive integrations with Akka Streams (20)

PDF
Akka streams - Umeå java usergroup
Johan Andrén
 
PDF
Reactive stream processing using Akka streams
Johan Andrén
 
PDF
Asynchronous stream processing with Akka Streams
Johan Andrén
 
PDF
Reactive streams processing using Akka Streams
Johan Andrén
 
PDF
Scala usergroup stockholm - reactive integrations with akka streams
Johan Andrén
 
PDF
Building Stateful Microservices With Akka
Yaroslav Tkachenko
 
PPTX
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Kafka
Akara Sucharitakul
 
PPTX
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
PDF
Reactive Streams 1.0 and Akka Streams
Dean Wampler
 
PDF
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Lightbend
 
PDF
Let the alpakka pull your stream
Enno Runne
 
PDF
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Lightbend
 
PDF
Building scalable rest service using Akka HTTP
datamantra
 
PPT
Server side JavaScript: going all the way
Oleg Podsechin
 
PPTX
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
PDF
Introduction to apache kafka, confluent and why they matter
Paolo Castagna
 
PDF
Streaming Design Patterns Using Alpakka Kafka Connector (Sean Glover, Lightbe...
confluent
 
PPT
JS everywhere 2011
Oleg Podsechin
 
ODP
Introduction to Akka Streams [Part-I]
Knoldus Inc.
 
PDF
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Twilio Inc
 
Akka streams - Umeå java usergroup
Johan Andrén
 
Reactive stream processing using Akka streams
Johan Andrén
 
Asynchronous stream processing with Akka Streams
Johan Andrén
 
Reactive streams processing using Akka Streams
Johan Andrén
 
Scala usergroup stockholm - reactive integrations with akka streams
Johan Andrén
 
Building Stateful Microservices With Akka
Yaroslav Tkachenko
 
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Kafka
Akara Sucharitakul
 
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
Reactive Streams 1.0 and Akka Streams
Dean Wampler
 
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Lightbend
 
Let the alpakka pull your stream
Enno Runne
 
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Lightbend
 
Building scalable rest service using Akka HTTP
datamantra
 
Server side JavaScript: going all the way
Oleg Podsechin
 
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Introduction to apache kafka, confluent and why they matter
Paolo Castagna
 
Streaming Design Patterns Using Alpakka Kafka Connector (Sean Glover, Lightbe...
confluent
 
JS everywhere 2011
Oleg Podsechin
 
Introduction to Akka Streams [Part-I]
Knoldus Inc.
 
Asynchronous Architectures for Implementing Scalable Cloud Services - Evan Co...
Twilio Inc
 
Ad

More from Konrad Malawski (10)

PDF
Akka Typed (quick talk) - JFokus 2018
Konrad Malawski
 
PDF
Krakow communities @ 2016
Konrad Malawski
 
PDF
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
Konrad Malawski
 
PDF
Zen of Akka
Konrad Malawski
 
PDF
Distributed Consensus A.K.A. "What do we eat for lunch?"
Konrad Malawski
 
PDF
Open soucerers - jak zacząć swoją przygodę z open source
Konrad Malawski
 
PDF
HBase RowKey design for Akka Persistence
Konrad Malawski
 
PDF
Scalding - the not-so-basics @ ScalaDays 2014
Konrad Malawski
 
PDF
DDDing Tools = Akka Persistence
Konrad Malawski
 
PDF
Akka persistence == event sourcing in 30 minutes
Konrad Malawski
 
Akka Typed (quick talk) - JFokus 2018
Konrad Malawski
 
Krakow communities @ 2016
Konrad Malawski
 
100th SCKRK Meeting - best software engineering papers of 5 years of SCKRK
Konrad Malawski
 
Zen of Akka
Konrad Malawski
 
Distributed Consensus A.K.A. "What do we eat for lunch?"
Konrad Malawski
 
Open soucerers - jak zacząć swoją przygodę z open source
Konrad Malawski
 
HBase RowKey design for Akka Persistence
Konrad Malawski
 
Scalding - the not-so-basics @ ScalaDays 2014
Konrad Malawski
 
DDDing Tools = Akka Persistence
Konrad Malawski
 
Akka persistence == event sourcing in 30 minutes
Konrad Malawski
 

Recently uploaded (20)

PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
PDF
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
“A Re-imagination of Embedded Vision System Design,” a Presentation from Imag...
Edge AI and Vision Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 

Reactive integrations with Akka Streams

  • 1. akka streams Reactive Integrations with that just work™ Johan Andrén Konrad Malawski
  • 3. Konrad `ktoso` Malawski Akka Team, Reactive Streams TCK, Persistence, HTTP
  • 4. Make building powerful concurrent & distributed applications simple. Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM
  • 5. Actors – simple & high performance concurrency Cluster / Remoting – location transparency, resilience Cluster tools – and more prepackaged patterns Streams – back-pressured stream processing Persistence – Event Sourcing HTTP – complete, fully async and reactive HTTP Server Official Kafka, Cassandra, DynamoDB integrations, tons more in the community Complete Java & Scala APIs for all features What’s in the toolkit?
  • 8. akka streams Asynchronous back pressured stream processing Source Sink Flow
  • 9. akka streams Asynchronous back pressured stream processing Source Sink (possible) asynchronous boundaries Flow
  • 10. akka streams Asynchronous back pressured stream processing Source Sink 10 msg/s 1 msg/s OutOfMemoryError!! Flow
  • 11. akka streams Asynchronous back pressured stream processing Source Sink 10 msg/s 1 msg/s hand me 3 morehand me 3 more 1 msg/s Flow
  • 12. akka streams Not only linear streams Source SinkFlow Source Sink Flow Flow
  • 13. Reactive Streams Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. This encompasses efforts aimed at runtime environments as well as network protocols http://www.reactive-streams.org
  • 14. Part of JDK 9 java.util.concurrent.Flow
  • 15. Reactive Streams RS Library A RS library B async boundary
  • 16. Reactive Streams RS Library A RS library B async boundary Make building powerful concurrent & distributed applications simple.
  • 17. The API Akka Streams Complete and awesome Java and Scala APIs (Just like everything in Akka)
  • 18. Akka Streams in 20 seconds: Source<Integer, NotUsed> source = null;
 
 Flow<Integer, String, NotUsed> flow =
 Flow.<Integer>create().map((Integer n) -> n.toString());
 
 Sink<String, CompletionStage<Done>> sink =
 Sink.foreach(str -> System.out.println(str));
 
 RunnableGraph<NotUsed> runnable = source.via(flow).to(sink);
 
 runnable.run(materializer);

  • 19. Akka Streams in 20 seconds: CompletionStage<String> firstString =
 Source.single(1)
 .map(n -> n.toString())
 .runWith(Sink.head(), materializer);

  • 20. Source.single(1).map(i -> i.toString).runWith(Sink.head()) // types: _ Source<Int, NotUsed> Flow<Int, String, NotUsed> Sink<String, CompletionStage<String>> Akka Streams in 20 seconds:
  • 21. Source.single(1).map(i -> i.toString).runWith(Sink.head()) // types: _ Source<Int, NotUsed> Flow<Int, String, NotUsed> Sink<String, CompletionStage<String>> Akka Streams in 20 seconds:
  • 27. What is “materialization” really? Check out the “Implementing an akka-streams materializer for big data” talk later today.
  • 28. AlpakkaA community for Streams connectors http://blog.akka.io/integrations/2016/08/23/intro-alpakka
  • 29. Alpakka – a community for Stream connectors Threading & Concurrency in Akka Streams Explained (part I) Mastering GraphStages (part I, Introduction) Akka Streams Integration, codename Alpakka A gentle introduction to building Sinks and Sources using GraphStage APIs (Mastering GraphStages, Part II) Writing Akka Streams Connectors for existing APIs Flow control at the boundary of Akka Streams and a data provider Akka Streams Kafka 0.11
  • 30. Alpakka – a community for Stream connectors Existing examples: MQTT AMQP Streaming HTTP Streaming TCP Streaming FileIO Cassandra Queries “Reactive Kafka” (akka-stream-kafka) S3, SQS & other Amazon APIs Streaming JSON Streaming XML …
  • 31. Alpakka – a community for Stream connectors Demo
  • 32. Alpakka – a community for Stream connectors Demo
  • 33. Akka Streams & HTTP streams & HTTP
  • 34. A core feature not obvious to the untrained eye…! Akka Streams / HTTP Quiz time! TCP is a ______ protocol?
  • 35. A core feature not obvious to the untrained eye…! Akka Streams / HTTP Quiz time! TCP is a STREAMING protocol!
  • 36. Streaming in Akka HTTP http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala “Framed entity streaming” http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html HttpServer as a: Flow[HttpRequest, HttpResponse]
  • 37. Streaming in Akka HTTP HttpServer as a: Flow[HttpRequest, HttpResponse] HTTP Entity as a: Source[ByteString, _] http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala “Framed entity streaming” http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html
  • 38. Streaming in Akka HTTP HttpServer as a: Flow[HttpRequest, HttpResponse] HTTP Entity as a: Source[ByteString, _] Websocket connection as a: Flow[ws.Message, ws.Message] http://doc.akka.io/docs/akka/2.4/scala/stream/stream-customize.html#graphstage-scala “Framed entity streaming” http://doc.akka.io/docs/akka/2.4/java/http/routing-dsl/source-streaming-support.html
  • 39. It’s turtles buffers all the way down! xkcd.com
  • 42. Streaming from Akka HTTP No demand from TCP = No demand upstream = Source won’t generate tweets => Bounded memory stream processing! Demo
  • 43. Streaming from Akka HTTP (Java) public static void main(String[] args) { final ActorSystem system = ActorSystem.create(); final Materializer materializer = ActorMaterializer.create(system); final Http http = Http.get(system); final Source<Tweet, NotUsed> tweets = Source.repeat(new Tweet("Hello world")); final Route tweetsRoute = path("tweets", () -> completeWithSource(tweets, Jackson.marshaller(), EntityStreamingSupport.json()) ); final Flow<HttpRequest, HttpResponse, NotUsed> handler = tweetsRoute.flow(system, materializer); http.bindAndHandle(handler, ConnectHttp.toHost("localhost", 8080), materializer ); System.out.println("Running at http://localhost:8080"); }
  • 44. Streaming from Akka HTTP (Java) public static void main(String[] args) { final ActorSystem system = ActorSystem.create(); final Materializer materializer = ActorMaterializer.create(system); final Http http = Http.get(system); final Source<Tweet, NotUsed> tweets = Source.repeat(new Tweet("Hello world")); final Route tweetsRoute = path("tweets", () -> completeWithSource(tweets, Jackson.marshaller(), EntityStreamingSupport.json()) ); final Flow<HttpRequest, HttpResponse, NotUsed> handler = tweetsRoute.flow(system, materializer); http.bindAndHandle(handler, ConnectHttp.toHost("localhost", 8080), materializer ); System.out.println("Running at http://localhost:8080"); }
  • 45. Streaming from Akka HTTP (Scala) object Example extends App with SprayJsonSupport with DefaultJsonProtocol { import akka.http.scaladsl.server.Directives._ implicit val system = ActorSystem() implicit val mat = ActorMaterializer() implicit val jsonRenderingMode = EntityStreamingSupport.json() implicit val TweetFormat = jsonFormat1(Tweet) def tweetsStreamRoutes = path("tweets") { complete { Source.repeat(Tweet("")) } } Http().bindAndHandle(tweetsStreamRoutes, "127.0.0.1", 8080) System.out.println("Running at http://localhost:8080"); }
  • 46. Next steps for Akka Completely new Akka Remoting (goal: 700.000+ msg/s (!)), (it is built using Akka Streams, Aeron). More integrations for Akka Streams stages, project Alpakka. Reactive Kafka polishing with SoftwareMill, Krzysiek Ciesielski Akka Typed progressing again, likely towards 3.0. Akka HTTP 2.0 Proof of Concept in progress. Collaboration with Reactive Sockets
  • 47. Ready to adopt on prod?
  • 49. Akka <3 contributions Easy to contribute tickets: https://github.com/akka/akka/issues?q=is%3Aissue+is%3Aopen+label%3Aeasy-to-contribute https://github.com/akka/akka/issues?q=is%3Aissue+is%3Aopen+label%3A%22nice-to-have+%28low-prio%29%22 Akka Stream Contrib https://github.com/akka/akka-stream-contrib Mailing list: https://groups.google.com/group/akka-user Public chat rooms: http://gitter.im/akka/dev developing Akka http://gitter.im/akka/akka using Akka
  • 51. Further reading: Reactive Streams: reactive-streams.org Akka documentation: akka.io/docs Free O’Reilly report – very out soon. Example Sources: ktoso/akka-streams-alpakka-talk-demos-2016 Get involved: sources: github.com/akka/akka mailing list: akka-user @ google groups gitter channel: https://gitter.im/akka/akka Contact: Konrad [email protected] Malawski http://kto.so / @ktosopl