pika

Multiple consumer in rabbitmq for multiple queue

倖福魔咒の 提交于 2020-02-25 01:51:16
问题 I have 2 queues, say q1 and q2, which corresponds to e1 and e2 exchanges with binding key b1 and b2. I want to run consumer functions in parallel, say c1 and c2 which will listen to q1 and q2 respectively. I tried the following way: def c1(): connection = pika.BlockingConnection(pika.ConnectionParameters(host=constants.rmqHostIp)) channel = connection.channel() channel.exchange_declare(exchange='e1', durable='true', type='topic') result = channel.queue_declare(durable='false', queue='q1')

19.python笔记之Rabbitmq

偶尔善良 提交于 2020-02-13 15:31:06
RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统。他遵循Mozilla Public License开源协议。 MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法。应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们。消 息传递指的是程序之间通过在消息中发送数据进行通信,而不是通过直接调用彼此来通信,直接调用通常是用于诸如远程过程调用的技术。排队指的是应用程序通过 队列来通信。队列的使用除去了接收和发送应用程序同时执行的要求。 RabbitMQ安装 1.linux 安装配置epel源 $ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm 安装erlang $ yum -y install erlang 安装RabbitMQ $ yum -y install rabbitmq-server service rabbitmq-server start/stop 2.安装python API pip install pika or easy_install pika 先来一个基于Queue实现生产者消费者模型试试水 #!/usr/bin/env python3 #coding:utf8

解决pika报错basic_consume() got multiple values for keyword argument ‘queue’

。_饼干妹妹 提交于 2020-02-04 13:18:14
在使用pika连接rabbitmq时,写入消息正常,但是消费的时候报错: TypeError: basic_consume() got multiple values for argument ‘queue’ 查了一下资料,是Pika版本问题,新安装的1.10版本,不适配. 解决方法1 指定安装0.12版本Pika pip install pika==0.12 方法2: channel.basic_consume( callback, # 消费消息 queue=‘hari’, no_ack=True) 修改为 channel.basic_consume(‘hari’, callback) 不同版本参数位置不一样导致的问题。 来源: CSDN 作者: 穆如清风s 链接: https://blog.csdn.net/fly0512/article/details/104167677

rabbitMQ队列使用及常用命令

房东的猫 提交于 2020-01-24 00:47:01
一、RabbitMQ常用命令 启动监控管理器: rabbitmq-plugins enable rabbitmq_management 关闭监控管理器: rabbitmq-plugins disable rabbitmq_management 启动rabbitmq: rabbitmq-service start 关闭rabbitmq: rabbitmq-service stop 查看所有的队列: rabbitmqctl list_queues 清除所有的队列: rabbitmqctl reset 关闭应用: rabbitmqctl stop_app 启动应用: rabbitmqctl start_app 用户和权限设置(后面用处) 添加用户: rabbitmqctl add_user username password 分配角色: rabbitmqctl set_user_tags username administrator 新增虚拟主机: rabbitmqctl add_vhost vhost_name 将新虚拟主机授权给新用户: rabbitmqctl set_permissions -p vhost_name username '.*' '.*' '.*' 角色说明 none 最小权限角色 management 管理员角色 policymaker 决策者

How to pause and resume consumption gracefully in rabbitmq, pika python

最后都变了- 提交于 2020-01-14 08:52:51
问题 I'm using basic_consume() for receiving messages and basic_cancel for canceling consuming, but there is a problem. Here is the code of pika.channel def basic_consume(self, consumer_callback, queue='', no_ack=False, exclusive=False, consumer_tag=None): """Sends the AMQP command Basic.Consume to the broker and binds messages for the consumer_tag to the consumer callback. If you do not pass in a consumer_tag, one will be automatically generated for you. Returns the consumer tag. For more

Pika 连接 rabbitmq 集群

余生颓废 提交于 2020-01-14 00:27:00
使用 Pika 连接 rabbitmq 集群 使用 python 编程经常会用到 pika 来向 rabbitmq 发送消息,单个 rabbitmq 节点连接比较简单,本文介绍使用 rabbitmq 集群情况下的连接方式。 vip 连接方式 在 client 与 rabbitmq server 之间通过 haproxy 等负载均衡来提供 vip,我使用的环境就是采用这种方式,但是遇到某一节点挂掉时再访问 vip 连接 rabbitmq 集群会连接失败,常见 log 如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <URLParameters host=10.10.11.1 port=5672 virtual_host=/ ssl=False> DEBUG:pika.adapters.select_connection:Using EPollPoller DEBUG:pika.callback:Added: { 'callback' : <bound method SelectConnection._on_connection_start of <SelectConnection CLOSED socket=None params =<URLParameters host=10.10.11.1 port=5672

“Error: Failed to initialize erlang distribution:” trying to run “rabbitmqctl status”

醉酒当歌 提交于 2020-01-04 02:18:12
问题 This question has been asked before (RabbitMQ Failed to initialize erlang distribution), but I haven't been able to find out how to fix it from the existing answers. Following https://www.rabbitmq.com/man/rabbitmqctl.1.man.html, I'd like to run the rabbitmqctl status command to display information about the RabbitMQ broker. However, I get an error message: kurt@kurt-ThinkPad:~$ rabbitmqctl status Error: Failed to initialize erlang distribution: {{shutdown, {failed_to_start_child, net_kernel,

rabbitmq消息队列

為{幸葍}努か 提交于 2020-01-02 21:42:40
rabbitmq消息队列的学习 1.优点:能够保证消息数据持久化,不丢失 安装rabbitmq 1.安装erlang $ yum -y install erlang2.安装RabbitMQ $ yum -y install rabbitmq-server3.启动(无用户名密码): systemctl start rabbitmq-server 查看是否启动: netstat -tunlp 0 0.0.0.0:4369 0.0.0.0:* LISTEN 3134/epmd 4.开启rabbitmq的web控制台 #开启web界面rabbitmqrabbitmq-plugins enable rabbitmq_management浏览器访问: http://192.168.91.128:15672/ 5.重启rabbitmq systemctl restart rabbitmq-server 6.创建rabbitmq用户 # 设置新用户kevins 密码123sudo rabbitmqctl add_user kevins 123 7. 设置用户为admin角色sudo rabbitmqctl set_user_tags kevins administrator 8.允许kevins用户对所有的队列进行读写 sudo rabbitmqctl set_permissions -p "/"

Pass the url into the parse method in scrapy that was consumed from RabbitMQ

拥有回忆 提交于 2019-12-24 01:49:32
问题 I am using the scrapy to consume the message(url) from the RabbitMQ,But When I use the yield to call the parse method passing my url as parameters .The program does not comes inside the callback method.Below is the foloowing code of my spider # -*- coding: utf-8 -*- import scrapy import pika from scrapy import cmdline import json class MydeletespiderSpider(scrapy.Spider): name = 'Mydeletespider' allowed_domains = [] start_urls = [] def callback(self,ch, method, properties, body): print(" [x]

Keep pika BlockingConnection alive without disabling heartbeat

点点圈 提交于 2019-12-23 16:35:45
问题 I am developing an RabbitMQ consumer with pika 0.10.0, and python 2.7 version.In my consumer client, I have a process that runs for a time period depending on input message. It can vary from 3 to 40 minutes. I do not want to disable heartbeat. Instead I am looking for some collback mechanism that can keep the connection alive until the delivery_tag is sent back. Is that possible? Few link I got, all are suggesting to disable the heartbeat as workaround. But I do not want to disable it. Ref: