RabbitMQ

 

What is RabbitMQ?

Based on AMQP protocol, RabbitMQ is an open source message queuing broker which desired for intercommunication message passing between software components, achieving many capabilities which do not have out of the box with simple TCP sockets.

Install on Ubuntu (root privilege):

apt-get install rabbitmq-server

rabbitmq-plugins enable rabbitmq_management

wget http://localhost:15672/cli/rabbitmqadmin -o /opt/rabbitmqadmin

chmod +x /opt/rabbitmqadmin

apt-get install python2.7

default credentials for web interface: guest/guest

find the UI at: http://localhost:15672

 

Controlling rabbitmq by command line:

rabbitmqctl stop
rabbitmqctl status
rabbitmqctl list­_queues
rabbitmqctl list_users
rabbitmqctl list_bindings
rabbitmqctl list_channels
rabbitmqctl list_exchanges

Connections

TCP connection from  AMQP client.

Settings are configured from client.

Channels

From each connection one can have one of more channels.

Usually used to open a channel from each thread.

Settings are configured from client.

Exchanges

Entry point for queues. Exchange have a logic to send for queues the messages.

For instance message to one queue only, or broadcast to many queues.

Types:

  • Direct
  • Fanout
  • Headers
  • Topic

There is always default exchange which is direct. Name is empty string.

Queues

Contains messages at the end. This is the storage for messages.

Binding

Bind between exchange and queue.

Configurable from the server within Queues menu.

If you do not set any binding, the default binding is to the default exchange (AMQP default).

Note that several exchanges can be bound to queue, thus queue can get from many sources.

Diagram

Connection -> Channel -> Exchange -> Bind -> Queue

Java Implementation

With Spring – https://spring.io/guides/gs/messaging-rabbitmq/

one example, explains good:  https://projects.spring.io/spring-amqp/

spring amqp reference: http://docs.spring.io/spring-amqp/reference/html/_reference.html

 

Further Reading

https://www.rabbitmq.com/tutorials/amqp-concepts.html

https://www.youtube.com/watch?v=ABGMjX4K0D8

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *