RABBITMQ the specific implementation of the message to the producer and consumer of the column Springboot

Source: Internet
Author: User
Tags message queue rabbitmq

RabbitMQ Basic Introduction

RABBITMQ's design philosophy is. Whenever there is a queue to receive messages. The message will be stored in the queue. Until subscribers are taken away. . If there is no message queue that can receive this message. The default is to discard this message.

My function is to implement the remote implementation of the two

Publisher:

Is the producer of message, publisher this clients produces some message.

Consumer:

Message consumer, Publisher generated the message, eventually to reach consumer this clients, for consumption.

Exchange:

Specifies the rule by which the message is routed to which Queue,message message first arrives at Exchange, and the server assumes responsibility for receiving a message from produce.

Queue:

The message that arrives at exchange, according to the established rules (Routing key) arrives the corresponding queue, in the server assumes the load message, is the message container, waits to be consumed.

Routing Key:

There is a black line hidden between Exchange and queue, which can be seen as a routing key,exchange is a message sent to the corresponding queue based on these well-defined routing keys. Is the bridge between Exchange and queue.

Broker:

This broker is not understood before, in fact broker is the application to receive and distribute messages, that is to say, RABBITMQ server is message Broker.

VirtualHost:

Virtual host, a broker can open multiple virtualhost, its role is to be used as a separate user permissions.

Connection:

is a TCP connection between the Publisher/consumer and the broker. The disconnected operation only occurs on the Publisher/consumer side, and the broker does not disconnect unless there is a network failure or a problem with the broker service.

Connection:channel:

If you build a connection every time you visit RABBITMQ, the overhead of building a TCP connection when the volume of messages is large, the result is inefficiency.

The client on the left sends a message to the client on the right, the process:
First: Get conection
Second: access to channel
Third: Define Exchange,queue
IV: Use a routingkey to binding the queue to an exchange
V: Send messages to the corresponding queue by specifying an exchange and a routingkey.
Sixth:consumer also acquires connection at the time of receiving, then gets the channel, then assigns a queue to the queue to fetch messages, it does not care about exchange,routingkey and how binding, Go to the corresponding queue and fetch the message.

A Publisher client sends a message, which Consumer client can receive a message that is on the exchange,routingkey,queue relationship.

RABBITMQ's simple theoretical knowledge introduces so much, the next blog introduces RABBITMQ on the CentoOS7 installation and configuration.

The first thing to do is to differentiate the AMQP protocol mandatory and immediate flag bits.

Mandatory and immediate are the two flags in the Basic.pulish method in the AMQP protocol that have the ability to return messages to the producer when they are unreachable in the message delivery process. The specific difference is:
1. Mandatory flag bit
When the mandatory flag bit is set to true, if Exchange cannot find a qualifying queue based on its type and message Routekey, The Basic.return method is called to return the message to the producer, and when mandatory is set to false, the broker throws the message directly.
2. Immediate flag bit
When the immediate flag bit is set to true, this message is not placed in the queue if Exchange finds that there are no consumers on the corresponding queue when the message is route to queue (s). When all the queues (one or more) associated with the message Routekey do not have a consumer, the message is returned to the producer through the Basic.return method.

If you want to use RabbitMQ you need to install the Erlang virtual machine in the installation of RabbitMQ Server specific implementation please view my previous blog

For a specific code reference, please refer to the Springboot +maven +idea of conscience making environment

Https://gitee.com/xdymemory00/RabbitMQ.git

RABBITMQ the specific implementation of the message to the producer and consumer of the column Springboot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.