Akka HTTP offers a general toolkit for providing and consuming HTTP-based services. The Akka HTTP modules implement a full server and client-side HTTP stack on the top of Akka Actor and Akka Streams
ICT role in 21st century education and its challenges
Akka HTTP with Scala
1. Presented By: Mohd Alimuddin
Software Trainee Intern
Akka HTTP with
Scala
2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
3. Our Agenda
What is Akka HTTP?
02 What is Akka and Akka Actors?
03 What is Akka Streams?
Marshalling & Unmarshalling
05
Low-Level API
01
04
05
High-Level API
06
07 Demo
4. What is Akka HTTP?
● Akka HTTP is a suite of libraries whose focuses is on HTTP integration of an
application.
● Akka HTTP is based on Akka actors and Akka streams.
● It is fully asynchronous and non blocking.
● Akka HTTP is not a framework but a toolkit which means it can be used on the
top of other framework such as Play and Lagom.
5. What is Akka and Akka Actors?
● Akka is an free and open source toolkit which is used to make highly
concurrent, distributed and fault tolerant applications on JVM.
● Akka uses actor model system which first introduced by Carl Eddie Hewitt in
1973.
● Actors represents computation unit which encapsulates its state and
application logic.
● Each actors uses asynchronous messages to interact with other actors and
actors uses mailbox to process all the messages.
6. Akka Actors
● Messages are handled by Message Handler and are extracted from the
mailbox in order of FIFO.
● Actors guarantees the message order is always maintained.
● Actors guarantees the messages are never duplicated.
7. What is Akka streams ?
● Akka streams implements Reactive streams using Akka actors concurrent
model.
● Akka streams has three major components Source, Flow and Sink which are
equivalent of Publisher, Processor and Subscriber.
● Source emits element or data asynchronously
● Flow transform elements, can perform computations
● Sink receives elements
Source
Flow
Sink
8. Marshalling and Unmarshalling
● In Akka HTTP, marshalling means the conversion of an object of type T into a
lower-level target, e.g a MessageEntity or HttpRequest or HttpResponse.
Marshalling is also known as Serialization or Pickling.
● In Akka HTTP, unmarshalling means the conversion of a lower-level source
object e.g MessageEntity or HttpRequest or HttpResponse into a instance of
type T. Unmarshalling is also known as Deserialization or Unpickling
9. Low-Level API
● The low-level Akka HTTP server API allows for handling connections or individual
request by accepting HTTP Requests and answering them by producing HTTP
Responses.
● This is provided by the akka-http-core module.
● Low Level API based simply on mapping request to response.
10. High-Level API
● Low Level API becomes uneasy to handle when we need to create a large
number of routes and complex applications. To solve this we use High-Level
API.
● High-Level API can be divided into two important parts-
● Directives
● Routes
11. Directives & Routes
● A Directives is a small building block used for creating arbitrary complex
route structures.
● Routes are highly specialized functions that take a RequestContext and
eventually complete it which happens asynchronously.
● Each Routes is composed of one or more Directives that handles one specific
kind of request.
type Route = RequestContext => Future[RouteResult]