RabbitMQ is an open source message broker and queueing server that can be used to let disparate applications share data via a common protocol, or to simply queue jobs for processing by distributed workers. It doesn’t matter whether your project is big or small: RabbitMQ can adapt to your needs. Do you want to quickly prototype one of your application components in language X and be sure you can easily switch it tomorrow to a more performant language? RabbitMQ can help you by decoupling the communication protocol. Do you need to be able to process image uploads for your social website as they arrive, while adding or removing workers with ease? You can use Rabbit queues to store jobs and let the broker perform the load balancing and job distribution for you. Problems like these can be easily and quickly solved by using RabbitMQ; this book is here to show you how to best implement your architectures around messaging.
Programming your application is one thing—keeping your application up and running is where the challenge starts. Don’t worry; this book also covers best practices for RabbitMQ administration, clustering, securing, and monitoring, so you can also learn the operational side of things.
Finally, we’ll get into RabbitMQ’s brain and those inner details that will let you understand the system resources used by the broker so you can perform capacity planning while you design your architectures. Also, you’ll learn how to extend the broker by installing plugins and by creating your own, because, why not? Get your editor ready because you’ll be coding in Python, PHP, Erlang, Java, and C#.
Chapter 1 explains the origin of the AMQP protocol, how RabbitMQ was born, and what industry problems it came to solve. Next, you’ll install the server and create your first Hello World program that will send data via RabbitMQ.
Chapter 2 immerses you in the world of messaging. We go from basic concepts up to seeing how to map those concepts in AMQP (the protocol used by RabbitMQ). Once you’re past that, you’ll learn about message durability and what happens in the life of a message from being published to getting consumed on the other end of the network.
Chapter 3 shows the basics of server management. You’ll see how to start and stop nodes, how to configure permissions, and how to get statistics about what’s happening on the server. And we give you some useful tips for troubleshooting the server.
Chapter 4 teaches you about messaging patterns and best practices. You’ll learn about fire-and-forget models, RPC architectures, and much more.
Chapter 5 starts a series of three chapters on RabbitMQ clustering and setup for high availability. Here you’ll set up a RabbitMQ cluster both on your local machine and on physical servers. You’ll learn how to upgrade a cluster of RabbitMQ nodes and how to use mirrored queues.
Chapter 6 discusses how to load balance a set of RabbitMQ brokers using HAProxy while teaching how to create smart messaging clients that know how to reconnect to the broker in case of failures.
Chapter 7 ends the series on high availability by explaining how active/standby broker pairs work. You’ll also learn about the Shovel plugin that allows RabbitMQ to replicate data across data centers.
Chapter 8 is where RabbitMQ administration goes visual. You’ll learn about the RabbitMQ Management plugin and its web interface, but we don’t stop there: we also perform an overview of the REST API offered by the plugin.
Chapter 9 builds from the previous chapter by explaining the REST API in detail. Here you’ll learn how most of the administration tasks can be performed from your code by using this API. Provisioning new users and virtual hosts for your applications was never so easy.
Chapter 10 teaches you how to monitor RabbitMQ, from Nagios checks to using AMQP and the REST API to monitor the server internal state. You’ll learn what you can do to detect problems before they happen.
Chapter 11 explains in detail the inner workings of exchanges (the routing algorithms used by RabbitMQ). We go into the details of the resources used by your messaging fabric to see what to expect from your architectural decisions. We also cover the security side of things by teaching you to enable SSL connections for your applications.
Chapter 12 ends the book by showing how to extend RabbitMQ’s behavior both by adding new plugins created by others and by creating your own plugin.
All source code in listings or in text is in a fixed-width font like this to separate it from ordinary text. Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.
Since one of RabbitMQ’s greatest strengths is gluing together applications written in different languages, we use both Python and PHP as the primary example languages (with a little .NET and Java thrown in for good measure in the appendixes). But we want our examples to be as widely usable as possible to readers from all languages. Since we can’t convert every example into every language, we’ve posted a Github repository so you can contribute too: https://github.com/rabbitinaction/sourcecode.
In the official Github repository you’ll find the latest versions of the example code from the book, along with a number of those examples already converted by other readers into languages like Ruby. Don’t see your favorite language? Fork the repository and add it! Then just send us a pull request and we’ll do our best to incorporate your versions of the examples. (Note: you must use the same BSD license as our code for us to pull your changes in.)
If you’d like the canonical and truly “official” copies of the examples from RabbitMQ in Action, you can download them from the publisher’s website: http://manning.com/RabbitMQinAction. The exact code as it appears in the latest published edition of the book will always be posted there.
The purchase of RabbitMQ in Action includes free access to a private forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and other users. You can access and subscribe to the forum at www.manning.com/RabbitMQinAction. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct in the forum.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It isn’t a commitment to any specific amount of participation on the part of the authors, whose contribution to the book’s forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions, lest their interest stray!
The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
Alvaro Videla is a developer and architect specializing in MQ-based applications. He speaks about RabbitMQ at conferences throughout Asia, Europe, and the U.S.
Jason J. W. Williams is CTO of DigiTar, a messaging service provider, where he directs design and development, including using RabbitMQ for real-time analysis operations since 2008.