rabbitmq 消息持久化

版权声明:本文为博主原创文章,未经博主允许不得转载。
#-*- coding: UTF-8 -*-
import pika
cred = pika.PlainCredentials('zxl','pwd') #账号密码
params = pika.ConnectionParameters(host='192.168.110.233',port=5672,credentials=cred) #条件设置
connection = pika.BlockingConnection(params) #给定条件
channel = connection.channel()
channel.queue_declare(queue='t_list',durable=True) #创建一个t_list 队列
for i in range(0,100):
content = ' ni hao is hello'+str(i)
channel.basic_publish(exchange='',
routing_key='t_list',
body=content,
properties=pika.BasicProperties(delivery_mode=2) #确保消息持久
)
print('send hello')
print(channel)
connection.close()
receive 端
#-*- coding: UTF-8 -*-
import pika
import time
cred = pika.PlainCredentials('zxl','pwd') #账号密码
params = pika.ConnectionParameters(host='192.168.110.233',port=5672,credentials=cred) #条件设置
connection = pika.BlockingConnection(params) #给定条件
channel = connection.channel()
channel.queue_declare(queue='t_list',durable=True) def callback(ch,method,properties,body):
print " [x] Received %r" % (body,)
time.sleep(2)
ch.basic_ack(delivery_tag = method.delivery_tag) channel.basic_consume(callback,queue = 't_list',no_ack = False) #no_ack 自动应答改为False
print("starting")
channel.start_consuming()
rabbitmq 消息持久化的更多相关文章
- Python RabbitMQ消息持久化
RabbitMQ消息持久化:就是将队列中的消息永久的存放在队列中. 处理方案: # 在实例化时加入durable=True来确认消息的实例化,客户端服务端都要写 channel.queue_dec ...
- rabbitmq 消息持久化之receive and send
二: 任务分发 &消息持久化 启用多个接收端的时候如果某一个receive 关闭要保证消息有反馈是否收到 send端 #-*- coding: UTF-8 -*-import pika ...
- Rabbitmq消息持久化
1.交换机持久化设置 exchange 持久化,在声明时指定 durable未true 2.队列持久化设置 queue 持久化,在声明时指定 durable 为true 3.消息持久化设置 Deliv ...
- RabbitMQ原理与相关操作(三)消息持久化
现在聊一下RabbitMQ消息持久化: 问题及方案描述 1.当有多个消费者同时收取消息,且每个消费者在接收消息的同时,还要处理其它的事情,且会消耗很长的时间.在此过程中可能会出现一些意外,比如消息接收 ...
- Python操作rabbitmq消息队列持久化
消息队列持久化 Python操作rabbit消息队列的持久化,如下: # 创建一个名为balance的队列,对queue进行durable持久化设为True(持久化第一步)channel.queue_ ...
- RabbitMQ 队列、消息持久化
RabbitMQ的消息队列的持久化是一个很不错的功能,设置也非常简单.如下代码: 1.设置队列持久化(在声明队列的时候设置) channel.QueueDeclare(queue: "q.l ...
- RabbitMQ入门_13_消息持久化
参考资料:https://www.rabbitmq.com/tutorials/tutorial-two-java.html 默认情况下,队列中的消息是不持久化的.如果 RabbitMQ 崩溃,队列中 ...
- RabbitMQ之消息持久化(转)
原文地址 https://blog.csdn.net/u013256816/article/details/60875666/ 消息的可靠性是RabbitMQ的一大特色,那么RabbitMQ是如何保证 ...
- RabbitMQ(三):消息持久化策略
原文:RabbitMQ(三):消息持久化策略 一.前言 在正常的服务器运行过程中,时常会面临服务器宕机重启的情况,那么我们的消息此时会如何呢?很不幸的事情就是,我们的消息可能会消失,这肯定不是我们希望 ...
随机推荐
- 转:etcd:从应用场景到实现原理的全方位解读
原文来自于:http://www.infoq.com/cn/articles/etcd-interpretation-application-scenario-implement-principle ...
- web sql Database
http://www.ibm.com/developerworks/cn/web/1108_zhaifeng_websqldb/ http://baishanheishui.iteye.com/blo ...
- 【POJ3691】 DNA repair (AC自动机+DP)
DNA repair Time Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Description B ...
- I2C总线之(一)---概述
概述: I²C 是Inter-Integrated Circuit的缩写,发音为"eye-squared cee" or "eye-two-cee" , 它是一 ...
- 14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用
14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用 Vsftp:/data01/mysql/zjzc# ls -lt ...
- C 常用的输入输出 栈 哈希 文件写读 实现 字符串处理
#include "stdafx.h"#include <stdio.h>#include <string.h>#include <stdlib.h& ...
- 【HDOJ】3367 Pseudoforest
并查集. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 10005 #d ...
- Node.js权威指南 (1) - Node.js介绍
1.1 Node.js概述 / 2 1.1.1 使用Node.js能够解决什么问题 / 2 1.1.2 实现高性能服务器 / 2 1.1.3 非阻塞型I/O及事件环机制 / 2 1.1.4 Node. ...
- [IoLanguage]Io Programming Guide[转]
Io Programming Guide Introduction Perspective Getting Started Downloading Installing Binaries Ru ...
- ipython notebook使用教程
在一次师兄(师兄博客地址)的例会汇报中,介绍了ipython notebook,当时觉得很酷炫,渐渐自己使用的时候才发现真的很强大.抽空整理下,找了些资料进行补充,并挨个进行了实现,留个笔记,也欢迎喜 ...