RabbitMQ Basic Concepts

Source: Internet
Author: User
Tags rabbitmq

Broker: The message negotiation device. The entity of Message Queuing, which listens for AMQ messages on ports such as TCP/IP

VHost: Virtual host. Functionally similar to Web-based virtual host, all the data according to the function or project is divided into different virtual host, the user is only granted access to the virtual host, and there is no other than this advanced access control measures. The client communicates with the broker by first establishing a connection that is limited to connecting users and virtual hosts.

Channel: Channels. The client declares a channel in the connection that is a logical connection between the client and the broker, and the client's operation is done through the channel. The specific operation requires the client to declare the corresponding component.

Common components:

-Exchanger (Exchange), which is the entity that sends the message; you can explicitly name

-Queue, which is the entity that receives the message, can be explicitly named, or, if not named, a queue is automatically generated and the name is random, and the randomly generated queue life cycle ends when the connection to which it was generated is broken

-Binder (BIND), which connects the exchanger to the queue and encapsulates the routing information of the message; the bound exchanger

Message: Messages

The composition of the message:

-metadata, such as the encoding of the content or the field that indicates the source.

-Flag bits that mark some of the security mechanisms at the time of message delivery.

-A special field is called Routing key.

Exchange: Exchanger

The exchanger is responsible for assigning the producer message to the queue by the specified rules

There are four of rules:

-Direct

-Topic

-Headers

-Fanout mass, to all bound queue

Queue: Queues

The broker stores the location of the message, which can be established by either producer and consumer.

Temporary queue: temporary queues

If you do not specify a queue name when declaring a queue, the declared queue will be an automatically named queue that will be automatically deleted when the connection is broken, because it belongs to the exclusive queue of a session, and it should end when the session ends.

The flow of messages from send to receive:

Message sending client-create channel-"exchange-" queue-"-create Channel-message receiving client (receiving process is uncertain)

The broker immediately deletes the message that is saved in the queue when the message is sent successfully. If a receipt is set, the broker performs the deletion after it receives the receipt.

Consumer shutdown, broker service shutdown can cause task failures and message loss.

-Consumer exception: message acknowledgment. If consumer occurs without receiving an exception message, the broker does not delete the message, but instead sends it again until the consumer return receipt is received.

-Broker Exception: Persistence of queues and messages.

-Queue persistence: The queue is persisted by setting the persisted parameter to true in the queue declaration, which must be set at the same time as producer and consumer, and the properties declared and existing in the queue cannot be modified, so a new queue needs to be re-declared

-Message Persistence: The parameters of the incoming message persisted when the message object is instantiated, based on the original message data

The default persistence is not very strong because the message is not saved for a short period of time after the broker accepts the message. In addition, RABBITMQ does not perform fsync on each message, so the message is likely to be in the memory cache and not actually written to disk. If you need more proper persistence, you need to use transaction transaction specific details: https://www.rabbitmq.com/confirms.html

Round-robin dispatching: Message polling distribution

If there is more than one worker,borker, the message is distributed to the worker in turn by odd even numbers;

Qos: Quality of Service

Messages are long and short, and if a worker distributes messages to a very long message, and one worker distributes them to a shorter one, a worker is busy and the other is busy. This requires balancing the distribution of messages.

Set QoS:Basic_qos (NULL, 1, NULL). 1 means that the broker sends only one message to the worker at a time, and if the worker does not complete the previous message and does not send a receipt to the broker, then the next message will not be sent to the worker. The next message is sent to an idle worker for processing.

(not to be continued ...)

RabbitMQ Basic Concepts

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.