rabbitmq news columns

RabbitMQ Profile

RabbitMQ official Chinese documents

What RabbitMQ can do for you?

  Messaging system allows software applications and extensions are connected to each other. These applications can be linked together to each other to form a larger application, or the user equipment and data connections. Asynchronous message reconciliation system to achieve an even application by separating the transmitting and receiving messages.

  Perhaps you are considering for data delivery, non-blocking operations or push notifications. Perhaps you want to implement publish / subscribe, asynchronous processing, or work queue. All these can be achieved through the messaging system.

  RabbitMQ is a message broker - a media message system. It provides a common platform to transmit and receive messages for your application, and to ensure safety in the message transmission process.

rabbitmq Highlights

  • Reliability : offers a variety of technology lets you trade-off between performance and reliability.
  • Flexible routing : before reaching the message queue are routed through the switch. rabbitmq provides built in switch type, the plurality of switches may be used in combination.
  • Cluster : RabbitMQ plurality of servers to the same LAN may be grouped together to use as an independent logical agent.
  • Joint : For servers, it requires more than loose and unreliable cluster links. To this end RabbitMQ provides a joint model.
  • Highly available queue : in the same cluster, the queue can be mirrored to multiple machines in order to ensure that when after some hardware failure, your information remains safe.
  • Multi-protocol : RabbitMQ supports a variety of messaging protocols messaging.
  • A wide range of clients : as long as you can think of almost all of its programming language adapted to the RabbitMQ client.
  • Visual tools : RabbitMQ visual management tool comes with an easy to use, it can help you monitor every aspect of message broker.
  • Track : If your messaging system abnormal behavior, RabbitMQ also provides tracking support, so you can find the problem.
  • Plug-in system : RabbitMQ comes with a variety of plug-ins to extend himself. You can even write your own plug-ins to use.

 

RabbitMQ installation

We installed rabbitmq on ubuntu

# Installation rabbitmq service
sudo apt install rabbitmq-server

 

sender1.py

. 1  # - * - Coding: UTF-. 8 - * - 
2  # @author: Liu Guoyang 
. 3  # @time: 2019/8/7 21:14 
. 4  # @file: sender1.py 
. 5  
. 6  
. 7  Import the PIKA
 . 8  
. 9 Credentials = pika.PlainCredentials ( ' alex ' , ' alex123 ' )   # server to create a user name and password 
10 Connection = pika.BlockingConnection (pika.ConnectionParameters (Host = " 192.168.150.135 " , = Credentials Credentials))
 11  # establish a rabbit agreement channel 
12= Channel connection.channel ()
 13 is  
14  # declare a Queue 
15 channel.queue_declare (Queue = ' Hello ' )
 16  
. 17  # message 
18 is  channel.basic_publish (
 . 19      Exchange = '' ,
 20 is      routing_key = ' Hello ' ,   # the message hello send queue name 
21 is      body = ' the hello World! '   # message to the queue, the content of the message 
22 is  )
 23 is  
24  Print ( " [X] sent 'the hello World!'")
25 connection.close()
sender1.py

 

receive1.py

 1 # -*- coding:utf-8 -*-
 2 # @Author:Liu Guoyang
 3 # @Time  :2019/8/7 23:43
 4 # @File  :receive1.py
 5 
 6 import pika
 7 import time
 8 
 9 credentials = pika.PlainCredentials('alex', 'alex123')
10 connection = pika.BlockingConnection(pika.ConnectionParameters(
11     '192.168.150.135', credentials=credentials))
12 
13 channel = connection.channel()
14 
15 # You may ask why we declare the queue again ‒ we have already declared it in our previous code.
16 # We could avoid that if we were sure that the queue already exists. For example if send.py program
17 # was run before. But we're not yet sure which program to run first. In such cases it's a good
18 # practice to repeat declaring the queue in both programs.
19 channel.queue_declare(queue='hello')
20 
21 
22 def callback(ch, method, properties, body):
23     print(" [x] Received %r" % body)
24 
25 
26 channel.basic_consume('hello', callback, False)
27 
28 print(' [*] Waiting for messages. To exit press CTRL+C')
29 channel.start_consuming()
receive1.py

 

Guess you like

Origin www.cnblogs.com/tom-blogs/p/11318784.html