Chapter 9. Routing messages

 

In this chapter

  • Using the enterprise integration router pattern
  • Scaling with Akka routers
  • Building a state-based router with become/unbecome

In the previous chapter we looked at enterprise integration patterns as a way to connect actors to solve a wide range of problems. Yet all those approaches involved processing incoming messages in the same way. But often, you need to handle messages differently.

Routers are essential when you want to scale up or out. For example, when you want to scale up, you need multiple instances of the same task, and routers will decide which instance will process the received message. We’ll start this chapter by describing the enterprise router pattern and examine the three reasons for using routing to control message flow:

  • Performance
  • Message content
  • State

We’ll then show you how to create routing processes for each of these patterns.

If performance or scaling is why you need to turn to a routing solution, you should use Akka’s built-in routers, because they’re optimized. Concerns with a message’s content or state, on the other hand, will point you to using normal actors.

9.1. The enterprise integration router pattern

9.2. Balance load using Akka routers

9.3. Implementing the router pattern using actors

9.4. Summary

sitemap