- RabbitMQ Cookbook
- Sigismondo Boschi Gabriele Santomaggio
- 580字
- 2021-07-19 18:52:47
Introduction
Advanced Message Queuing Protocol (AMQP) has been developed because of the need for interoperability among the many different messaging solutions, that were developed a few years ago by many different vendors such as IBM MQ-Series, TIBCO, or Microsoft MSMQ.
The AMQP 0-9-1 standard gives a complete specification of the protocol, particularly regarding:
- The API interface
- The wire protocol
RabbitMQ is a free and complete AMQP broker implementation. It implements version 0-9-1 of the AMQP specification; this is the most widespread version today and it is the last version that focuses on the client API. That's what we want to put the focus on, especially in this chapter.
On the other hand, AMQP 1.0 only defines the evolution of the wire-level protocol—the format of the data being passed at the application level—for the exchange of messages between two endpoints; so 0-9-1 is actually the most updated client library specification.
RabbitMQ includes:
- The broker itself, that is, the service that will actually handle the messages that are going to be sent and received by the applications
- The API implementations for Java, C#, and Erlang languages
It is also possible to use APIs for languages downloadable from the RabbitMQ site itself, from third-party sites, or even using AMQP APIs not strictly related to RabbitMQ (http://www.rabbitmq.com/devtools.html). Since the AMQP standard specifies the wire protocol, they are going to be mostly interoperable, except for some custom extensions. That will be discussed in detail in the next chapter.
In the course of the book we will particularly use some of the following APIs:
- The Java AMQP client library (http://www.rabbitmq.com/java-client.html)
- Pika, one of the Python AMQP client libraries (http://pypi.python.org/pypi/pika)
- The .NET/C# AMQP client (http://www.rabbitmq.com/dotnet.html)
- The RabbitMQ C client API (https://github.com/alanxz/rabbitmq-c)
- The Ruby client library (https://github.com/ruby-amqp/bunny)
In this first chapter we are mainly using Java since this language is widely used in enterprise software development, integration, and distribution. RabbitMQ is a perfect fit in this environment.
In order to run the examples in this recipe, you will first need to:
- Install Java JDK 1.6+
- Install the Java RabbitMQ client library
- Properly configure
CLASSPATH
and your preferred development environment (Eclipse, NetBeans, and so on) - Install the RabbitMQ server on a machine (this can be the same local machine)
The natural choice is to install it on your desktop (Windows, Linux, and Mac OS X are all fine choices), but you can also install it on one or more external servers; for example, virtual machines, physical servers, and Raspberry PI servers (http://www.raspberrypi.org/) on cloud service providers.
Most of the examples will work connecting to the RabbitMQ broker running on the localhost. If you have chosen to install or use RabbitMQ from a different machine, you will need to specify its hostname as a command-line parameter of the examples themselves, for example:
java -cp ./bin rmqexample.Publish [Rabbitmq-host]
For the examples involving Python, you will need Python 2.7+ installed and the Pika library, an AMQP implementation for Python (https://pypi.python.org/pypi/pika). The fastest way to install Pika is by using PIP (https://pypi.python.org/pypi/pip). In the command prompt, just type:
pip install pika
We will also present some recipes using .NET where the accent is mainly on interoperability.
You can download the working examples in their full form at http://www.packtpub.com/support.
The recipes presented in this chapter will tackle all the basic concepts exposed by AMQP, using RabbitMQ.
- 算法訓(xùn)練營:入門篇(全彩版)
- oreilly精品圖書:軟件開發(fā)者路線圖叢書(共8冊)
- Python自然語言處理(微課版)
- 網(wǎng)店設(shè)計看這本就夠了
- Effective Python Penetration Testing
- Learning Python by Building Games
- 編程菜鳥學(xué)Python數(shù)據(jù)分析
- 響應(yīng)式架構(gòu):消息模式Actor實現(xiàn)與Scala、Akka應(yīng)用集成
- Quantum Computing and Blockchain in Business
- Learning Node.js for .NET Developers
- 測試架構(gòu)師修煉之道:從測試工程師到測試架構(gòu)師
- .NET 4.0面向?qū)ο缶幊搪劊簯?yīng)用篇
- Python 3快速入門與實戰(zhàn)
- SQL Server on Linux
- Android嵌入式系統(tǒng)程序開發(fā)(基于Cortex-A8)