Restart associated service
Fondement des Systèmes repartis
TP1 : Serveur de messagerie pour les
applications réparties : RabbitMQ
The first part of this lab is to understand the RabbitMQ messaging distributed
systems by running same examples. Then, at the final step, you need to create
a distributed application that use communication based on RabbitMQ API.
3. Use the web interface
1. Installation Run the web RabbitMQ administration page : [Link]
Download the Server
Installer for Windows systems (from GitHub, recommended)
[Link] (form:
[Link]
Install the Server
RabbitMQ requires a 64-bit supported version of Erlang for Windows
to be installed before installing RabbitMQ server.
2. Setting web interface for RabbitMQ server
The management plugin is included in the RabbitMQ distribution.
Like any other plugin it must be enabled before it can be used. That's
done using rabbitmq-plugins: on the relative path (C:\Program
Files\RabbitMQ Server\rabbitmq_server-3.7.10\sbin) :
rabbitmq-plugins enable rabbitmq_management
1|Page
Use the web administration interface to create manually a Queue, then an
exchange, a binding to the new queue as the flowing figure. Make a test by
publishing/sending a message and then read/consume this message.
The following figures shows the step to realise that.
4. Send Client code: hello message
Write the following code and add libs to run it correctly.
2|Page
The message is end to the RabbitMQ server, that you can display 5. Receiving message from the RabbiMQ :
form web interface. Verify that on your server as in the following
figures. We're about to tell the server to deliver us the messages from the
queue. Since it will push us messages asynchronously, we provide a
callback in the form of an object that will buffer the messages until
we're ready to use them. We use the DeleverCallback interface to
receive message.
We also use basicConsume function that start a non-exclusive consumer,
with explicit acknowledgement and a server-generated consumerTag. The
consumerTag Specifies the identifier for the consumer. It is local to a
channel, so two clients can use the same consumer tag).
String basicConsume(String queue, DeliverCallback deliverCallback,
CancelCallback cancelCallback) throws IOException;
Write the following code for receive/consume the message:
3|Page
6. On using message exchange and routing:
The producer sends messages to an exchange (X). An exchange is a
very simple thing. On one side it receives messages from producers
and the other side it pushes them to queues.
The routing algorithm behind a direct exchange is simple - a
message goes to the queues whose binding key exactly
matches the routing key of the message.
In this section, we built a simple logging system. We were able to
broadcast log messages to many receivers. we will be able to direct
only critical error messages to the log file, while still being able to print
all of the log messages on the console.
The display result is :
Use the API documentation link to understand some specific codes:
[Link]
master/src/main/java/com/rabbitmq/client/[Link]
4|Page
7- Create a simple of collaborative text editing
There are many collaborative text edition applications provided in Internet.
It is one of the relevant examples of distributed applications where users can
share and modify at the same time a text to be edited on collaborative way.
5|Page
2. The second part of this application is to create exclusion to
access and modify text of the same synthesis or paragraph at the
same time form many users. As illustrated in the following, each
user has in his interface a set of paragraphs. Only one user can
edit at the same time in e paragraph. You need also to display the
assigned users to paragraphs if they are writing in. All
communications are made with RabbitMQ messaging. Each user
have his one program or process.
1. In this lab, we strat by creating a simple application that contains 2
tasks to edit 2 different sections of a text document, and one more
task (third) to read and display the text. The 3 tasks are distributed in
different computers and the communication will be held with
RabbitMQ. This is a start illustration of the application:
6|Page