Book Image

RabbitMQ Cookbook

Book Image

RabbitMQ Cookbook

Overview of this book

RabbitMQ is an open source message broker software (sometimes called message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. Messaging enables software applications to connect and scale. Applications can connect to each other as components of a larger application or to user devices and data. RabbitMQ Cookbook touches on all the aspects of RabbitMQ messaging. You will learn how to use this enabling technology for the solution of highly scalable problems dictated by the dynamic requirements of Web and mobile architectures, based for example on cloud computing platforms. This is a practical guide with several examples that will help you to understand the usefulness and the power of RabbitMQ. This book helps you learn the basic functionalities of RabbitMQ with simple examples which describe the use of RabbitMQ client APIs and how a RabbitMQ server works. You will find examples of RabbitMQ deployed in real-life use-cases, where its functionalities will be exploited combined with other technologies. This book helps you understand the advanced features of RabbitMQ that are useful for even the most demanding programmer. Over the course of the book, you will learn about the usage of basic AMQP functionalities and use RabbitMQ to let decoupled applications exchange messages as per enterprise integration applications. The same building blocks are used to implement the architecture of highly scalable applications like today's social networks, and they are presented in the book with some examples. You will also learn how to extend RabbitMQ functionalities by implementing Erlang plugins. This book combines information with detailed examples coupled with screenshots and diagrams to help you create a messaging application with ease.
Table of Contents (19 chapters)
RabbitMQ Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The RabbitMQ Cookbook covers RabbitMQ and the corresponding AMQP protocol.

Even the less-experienced programmer can find a lot of information that is useful to start developing messaging applications using RabbitMQ, especially in the first few chapters.

However, in order to fully appreciate some of the chapters of the book, the reader should also know the basic concepts about web and cloud applications.

The book is full of examples that show you how to use RabbitMQ in very disparate scenarios, in different technologies, right from single hosts to geographically replicated high-availability clusters. Mostly everyone working with these technologies will find a lot of useful information within this book.

What this book covers

Chapter 1, Working with AMQP, introduces the basic concepts of AMQP, the Advanced Message Queuing Protocol, on which RabbitMQ is based. It shows how the fire-and-forget messaging model works and how to use it from clients.

Chapter 2, Going beyond the AMQP Standard, covers the RabbitMQ extensions of AMQP and how they can be used to increase the efficiency of messaging applications.

Chapter 3, Managing RabbitMQ, explains how to configure RabbitMQ parameters, enable RabbitMQ plugins, and monitor RabbitMQ activities.

Chapter 4, Mixing Different Technologies, covers the integration of different technologies with other protocols, such as MQTT, STOMP, and JSON.

Chapter 5, Using RabbitMQ in Web Applications, shows how to develop web applications with RabbitMQ as a service bus.

Chapter 6, Developing Scalable Applications, explains how to create scalable and robust applications using RabbitMQ clustering.

Chapter 7, Developing High-availability Applications, covers the high-availability options offered by RabbitMQ.

Chapter 8, Performance Tuning for RabbitMQ, explains how to optimize the performance of applications based on RabbitMQ in different scenarios.

Chapter 9, Extending RabbitMQ Functionality, covers the use and development of RabbitMQ plugins.

Chapter 10, RabbitMQ on AWS, explains how to deploy RabbitMQ applications on Amazon Web Services.

Chapter 11, AMQP and Cloud Computing – RabbitMQ on PaaS, explains how to deploy and use RabbitMQ on Cloud Foundry.

Chapter 12, Managing RabbitMQ Error Conditions, explains how to diagnose and deal with RabbitMQ error conditions.

What you need for this book

You can use Linux/Unix, Mac OS X, or Windows as the operating system since RabbitMQ is cross-platform middleware. Most of the examples have been developed in Java, but to execute other recipes, you will also need:

  • Python

  • Ruby

  • .NET (here you will be bound to Windows only)

  • Erlang

  • Objective-C

  • JavaScript

The RabbitMQ Cookbook also covers the cloud computing world (both IaaS and PaaS). To utilize the respective chapters, you will need an account on:

  • Amazon Web Services (IaaS)

  • Cloud Foundry (PaaS)

Who this book is for

The RabbitMQ Cookbook is for software developers who want to develop distributed applications based on messaging. It’s assumed that the reader has some experience with multithreaded applications and distributed applications.

The reader should also know the basic concepts of web and cloud applications in order to follow the recipes specifically.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, folder names, filenames, file extensions, pathnames, are shown as follows: “Properly configure CLASSPATH and your preferred development environment”.

A block of code is set as follows:

ConnectionFactory factory = new ConnectionFactory();
String uri=”amqp://user:pass@hostname:port/vhost”;
factory.setUri(uri);

Any command-line input or output is written as follows:

java -cp ./bin  rmqexample.Publish [Rabbitmq-host]

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: “Configure the host by navigating to Edit configuration | services | endpoint | new.”

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.