RabbitMQ (Introductory Concepts)

         RabbitMQ is a reusable message system based on AMQP (Advanced Message Queuing Protocol). AMQP provides a standard advanced message queuing protocol of the application layer of unified message service, which is used for the design of message middleware.

The development language of RabbitMQ is Erlang, which enables completely different applications to share data. It is a great tool for decoupling in the program. When some logic in the program does not need to be returned in time and takes a long time, MQ can be used for asynchronous processing, which shortens the request response time and increases the throughput.

basic concept

1: Host: Server server host

          (name hostname, port port, VirtualHost virtual host, username username, password password)

2: Exchange: An exchange, which is used to specify what rules and queues the messages are routed to.

               (name, switch name, type switch type, whether Durable is persistent, whether AutoDelete is automatically deleted)

      The switch types include (topic, direct, fanout, x-delayed-message)

3: Queue: A queue, a container for messages, each message can be produced to one or more queues.

     (name: queue name, whether Durable is persistent, whether AutoDelete is automatically deleted, whether NoAck is a message confirmation)

4: RoutingKey: Routing keyword. Exchange delivers messages based on this.

5: Binding: Binding, which associates Exchange and Queue bindings according to routing keywords.

6: Channel: The transmission channel of the message. For each connection, multiple Channels can be established, and each Channel represents a session.

7: Producer: Producer. The program that sends the message.

8: Consumer: Consumer. The program that receives the message.

 

production/consumption process

  1: Set ConnectionFactory according to Server host address, port, virtual host, account and password

  2: Create a new connection NewConnection

  3: Create a channel CreateChannel

  4: Declare the creation of the queue QueueDeclare

  5: Send message Publish/receive message Consume

  6: Close the channel CloseChannel

  8: Close the connection CloseConnection

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325853359&siteId=291194637