RabbitMQ

概念

https://www.cnblogs.com/yihuihui/p/9095130.html
https://blog.csdn.net/whycold/article/details/41119807

CSDN
https://www.cnblogs.com/wt11/p/5970297.html
博客园
http://blog.ftofficer.com/2010/03/translation-rabbitmq-python-rabbits-and-warrens/

send.py

import sys

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()


channel.queue_declare(queue='hello')

message = ' '.join(sys.argv[1:]) or "Hello 1World!"
channel.basic_publish(exchange='',
                      routing_key='hello',
                      body=message)
print(" [x] Sent %r" % message)
connection.close()

service.py

import time

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()


channel.queue_declare(queue='hello')

def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
    time.sleep(body.count(b'.'))
    time.sleep(7)
    print(" [x] Done")

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=False)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

常用命令

第一步:
cd /usr/local/Cellar/rabbitmq/3.7.8/sbin
启动
./rabbitmq-server
停止
./rabbitmqctl stop

./rabbitmq-server stop
测试
 rabbitmqctl status
查看所有队列信息
./rabbitmqctl list_queues

1)首先关闭./rabbitmq: rabbitmqctl >stop_app

(2)还原: ./rabbitmqctl reset

(3)启动:./ rabbitmqctl start_app

(4)添加用户:./ rabbitmqctl add_user root root

(5)设置权限:./rabbitmqctl set_permissions -p / root "." "." ".*"

(6)查看用户:./ rabbitmqctl list_users

常用操作和用户设置

https://www.jianshu.com/p/e3af4cf97820

ubuntu安装

https://blog.csdn.net/sharetop/article/details/50523081

你可能感兴趣的:(RabbitMQ)