RABBITMQ message Persistence

Source: Internet
Author: User

RABBITMQ Message Persistence2016-02-18 11:19 224 people read comments (0) favorite reports Classification:synthesis (a)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

II: Task Distribution & Message Persistence When multiple receivers are enabled if a receive is turned off to ensure that the message has feedback whether it receives the send side
#-*-Coding:utf-8-*-
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 queue
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 End
#-*-Coding:utf-8-*-
Pika
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)

Callback (Ch,method,properties,body):
"[x] Received%r"% (body,)
Time.sleep (2)
CH method. Delivery_tag)

Channel.basic_consume (callback,queue = ' t_list ', No_ack = false) #no_ack Auto answer to False
Print ("Starting")
Channel.start_consuming ()

RABBITMQ message Persistence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.