Chapter 10. Message channels
In this chapter
- Direct messaging with point-to-point channels
- Flexible messaging with publish-subscribe channels
- Publishing and subscribing to the EventBus
- Reading undelivered messages using the dead-letter channel
- Achieving a higher level of guaranteed delivery with the guaranteed-delivery channel
- Guaranteeing delivery with the ReliableProxy
In this chapter we’ll take a closer look at the message channels that can be used to send messages from one actor to another. We’ll start with the two types of channels: point-to-point and publish-subscribe. Point-to-point is the channel we’ve used in all our examples until now, but sometimes we need a more flexible method to send messages to receivers. In the publish-subscribe section, we’ll describe a method to send messages to multiple receivers without the sender knowing which receivers need the message. The receivers are kept by the channel and can change during the operation of the application. Other names that are often used for these kinds of channels are EventQueue or EventBus. Akka has an EventStream that implements a publish-subscribe channel. But when this implementation isn’t sufficient, Akka has a collection of traits that helps to implement a custom publish-subscribe channel.