Akka, AMQP, Play, and Scala (a follow up)

So this weekend I was following along with a very helpful blog post when I realized that the way it’s implemented prevents proper application shutdown since the primary actor for consuming messages will block eternally.

Since I’m new to this I searched around for a bit more context or possible solutions but it really came down to actually reading the RabbitMQ api docs.

The solution in the post uses a deprecated class QueueingConsumer which provides the blocking api. But you don’t need to do this at all these days. Just implementing a simple subclass of the DefaultConsumer is sufficient for streaming messages into your actor system without having to manage your own threads or worry about proper shutdown.

Here is my MsgConsumer implementation:

And in your Global settings you need to have a setup similar to this:

I deviated a bit from the original post, but hopefully this is enough information to explain the solution I reached.