11 Akka ports

 

This chapter covers

  • Creating an HTTP server with Akka HTTP
  • Connecting through HTTP with actors from outside the cluster
  • Creating a gRPC server with Akka gRPC
  • Connecting through gRPC with actors from outside the cluster

In this chapter, you learn how to connect to an ActorSystem to send messages from the outside. This is done so that any application can interact with actors. You see 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 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 ActorSystem.

NOTE

The source code for this chapter is available at www.manning.com/books/akka-in-action-second-edition or https://github.com/franciscolopezsancho/akka-topics/tree/main/chapter11a. 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 servers

11.1.2 The path

11.1.3 Directives

11.1.4 Route directives

11.1.5 Marshalling and unmarshalling

11.1.6 Akka HTTP communicating with actors

11.2 Akka gRPC

11.2.1 The Protocol Buffers side

11.2.2 The RPC side

Summary