11 Akka ports
This chapter covers
- Creating an HTTP server with Akka HTTP
- Connecting through HTTP with actors from outside the cluster
- Creating an gRPC server with Akka gRPC
- Connecting through gRPC with actors from outside the cluster
In this chapter you will learn how to connect to an Actor system to send it messages from the outside. This is done so that any application can interact with Actors. You will learn how to create servers in Akka that provide endpoints that can be used by HTTP or gRPC clients.
11.1 Akka HTTP
This module builds on Akka Streams and shares its semantics. Its components are internally defined in terms of Sources
, Flows
and Sinks
. However, these are hidden and your interaction with this API is through an expressive DSL that lets you create URL paths, manage requests and responses, and more.
Akka HTTP is a very comprehensive module that covers HTTP clients, HTTP servers, JSON and XML encoding, caching, and anything else you can think of to serve or use HTTP endpoints. However, this chapter focuses on the HTTP server you need to expose your actor system.
IMPORTANT
You can use the following code companion https://github.com/franciscolopezsancho/akka-topics/tree/main/chapter11a to check out the source code for the following examples. You can find the contents of any snippet or listing in the .scala
file with the same name as the class
, object
or trait
.