How it works...
In this recipe, we covered how to create an Envelop case class where we can add additional information about a given message. In this particular example, the Envelope case class holds the message of type Any and a map of headers of type String to Any. The addition of this header happens in EnvelopingActor. This actor takes two parameters: the target actor where we will send the envelope and a function from Any to Headers that is used to generate the headers for a given message. When it receives a message, it calls the addHeaders function to create the headers and adds those to the envelope. Once the envelope is ready, it gets sent to the target actor.
In the EnvelopingActorApp object, we can see that we are defining the function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access