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.

11.1.1 Akka HTTP Server

 
 

11.1.2 Path

 
 

11.1.3 Directives

 
 

11.1.4 Route directives

 
 
 
 

11.1.5 Complete

 
 

11.1.6 Traversing the Route

 
 

11.1.7 Failing

 
 

11.1.8 Marshalling/Unmarshalling

 

11.1.9 Akka HTTP communicating to Actors

 
 
 
 

11.1.10 Transform the Request

 
 
 

11.1.11 Transform to Response

 
 
 

11.2 Akka gRPC

 
 
 
 

11.2.1 The Protocol buffers side

 
 

11.2.2 The RPC side

 
 

11.2.3 Akka gRPC

 
 

11.2.4 In action

 
 

11.2.5 Running the service

 
 
 

11.2.6 Akka gRPC with an Actor

 
 

11.2.7 Running the example

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest