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.
RabbitMQ Use Such as persistence, Transmission confirmation and release confirmation mechanisms to ensure reliability
Routing messages through switches. For typical routing functions, RabbitMQ Some built-in switches have been provided to implement. For more complex routing functions, Multiple Switches are bound together, This needs to be implemented through plug-ins
Multiple RabbitMQ Nodes can form a cluster, You can also dynamically expand the nodes in the cluster according to the actual business situation
Queues can be mirrored on machines in the cluster, Make the queue available even if some nodes have problems
RabbitMQ Besides native support AMQP agreement, And support STOMP, MQTT And other message middleware protocols
RabbitMQ Support for almost any common language, such as GO, Java, Python, Ruby, PHP etc.
RabbitMQ Provides an easy-to-use user interface, Enables users to monitor and manage messages, Nodes in the cluster, etc
RabbitMQ Many plug-ins are provided, To realize the extension from many aspects, Of course, you can also write your own plug-in
Simple producer production messages, Put in queue, Consumer consumption news
When producers produce news faster than consumers consume, You have to think about it work Working mode, This can increase processing speed and load work Patterns and single Similar model, It's just work Model than single There are more consumers in the model
Application scenarios : The use of simple message queues , One producer one consumer
The message producer sends the message to the switch according to the routing judgment, The route is a string (info) Currently generated messages carry routing characters ( Object method ), Switches are routed according to key. Only the upper route can be matched key Corresponding message queue, The corresponding consumer can consume the news
Topic pattern, A message is obtained by multiple consumers, The goal of the message queue You can use BindingKey, Use wildcards
Through remote procedure call
Responsible for protocol related message processing. That is, receiving messages from producers. Delivering messages to consumers. Process message confirmation, etc
It's the concrete form and engine of message storage. And to rabbit_amqqueue_process, it provides the relevant interface for calling
Messages is not posted directly in the queue, the user sends messages to the exchange, it is responsible for routing the messages to the queues. Exchange helps in receiving messages from the producer request and routes them by bindings and routings keys for messaging queues. It acts like a bindage, linking between an exchange and a queue.
The RabbitMQ server is a robust and scalable implementation of an AMQP broker. Running RabbitMQ-server in the foreground displays a banner message, and reports on progress in the startup sequence, concluding with the message "broker running", indicating that the RabbitMQ broker has been started successfully.
The rabbitmqadmin is a command-line tool that performs some of the same actions as the Web-based UI. It is shipped with the management plugin and provides a more convenient way for automating tasks. This command-line tool supports all versions of Python and can be downloaded after the management plugin is installed.
They enable you to have a single connection to the RabbiMQ server, but for different parts of your application they have sandboxed communication. Channels are how the RabbitMQ server communicates with your application. It hold one connection (instance) per client process and many channels in that process (instance)
The message structure in the RabbitMQ is divided into two parts. They are the payload and routing key.
The routing key is used to describe the payload passed by the system and the messaging system itself to determine who will be the receiver of the payload. The routing key also enables you to bind queues to exchanges to deliver the message to the queue based on the four types of exchanges.
Direct Exchanges - This type route the messages with a routing key equal to the routing key declared by the binding queue.
Fanout Exchanges - This type route the messages to all bound queues indiscriminately.
Topic Exchanges - This type route the messages to the queues if the routing key of the route is matched all or a portion of the matching patterns.
Headers Exchanges - This type route the messages based upon the matching of message headers to the expected headers which are specified in the binding queue.
One-Message-to-One-Consumer Model
This model is used to deliver each task to exactly one worker. The exchange types of this pattern are,
One-Message-to-Multiple-Consumers Model
In this model, one message is dispatched to multiple consumers. Some exchange types of this pattern are,
In general, a death letter queue (DLQ), also referred to as an undelivered-message queue, is a holding queue of messages that can not be sent to their destinations for some reason.
In RabbitMQ, the dead letter queue is service implementation to store messages that satisfy one or more of the following failure criteria.
A Virtual Host (a.k.a. ' vhost ') in AMQP is a namespace for objects such as Exchanges, Queues and Bindings. RabbitMQ utilizes more concrete implementation of virtual hosts, through effectively making them "virtual clusters" on top of the broker.
RabbitMQ uses Advanced Message Queuing Protocol (AMQP). Its an open standard layer used to communicates date across network by means of byte stream.
The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. AMQP 0-9-1 is a binary messaging protocol and semantic framework for microservices and enterprise messaging. RabbitMQ is based on AMQP 0-9-1 Protocol. RabbitMQ supports -
RabbitMQ Messaging Flow- Bindings are what connects the exchanges to queues.
STOMP is a simple text-oriented messaging protocol used by our UI Client(browser) to connect to enterprise message brokers.
Clients can use the SEND or SUBSCRIBE commands to send or subscribe for messages along with a "destination" header that describes what the message is about and who should receive it.
It defines a protocol for clients and servers to communicate with messaging semantics. It does not define any implementation details, but rather addresses an easy-to-implement wire protocol for messaging integrations. The protocol is broadly similar to HTTP, and works over TCP using the following commands:
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
spring:
rabbitmq:
listener:
simple:
retry:
enabled: true
initial-interval: 6s
max-attempts: 5
max-interval: 15s
multiplier: 4
Erlang is a general-purpose, concurrent, functional programming language, as well as a garbage-collected runtime system. The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. Since RabbitMQ is built on top of Erlang, we will first need to install Erlang beforing installing RabbitMQ.
sudo rabbitmqctl status
rabbitmqadmin list queues name
rabbitmqadmin delete queue name='queuename'
rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app
sudo -u rabbitmq rabbitmqctl stop
We can restart it like any other service:
sudo service rabbitmq-server restart
We get a specific control interface as well:
sudo rabbitmqctl "report"
sudo rabbitmqctl "reset"
CorelationId
15672