Python 官方文档:入门教程 => 点击学习
send.py#!/usr/bin/env python # -*- coding: UTF-8 -*- import pika import random credentials = pika.Plain
send.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import pika
import random
credentials = pika.PlainCredentials('root', '123456')
#这里可以连接远程IP,请记得打开远程端口
parameters = pika.ConnectionParameters('139.x.x.x',5672,'/',credentials)
connection = pika.BlockinGConnection(parameters)
channel = connection.channel()
#channel.queue_declare(queue='hello')
number = random.randint(1,1000)
body = 'hello world:%s' %number
channel.basic_publish(exchange='',
routing_key='hello',
body=body)
print " [x] Sent %s" %body
connection.close()
receice.py
#!/usr/bin/env Python
# -*- coding: UTF-8 -*-
import pika
import random
credentials = pika.PlainCredentials('root', '123456')
#这里可以连接远程IP,请记得打开远程端口
parameters = pika.ConnectionParameters('139.x.x.x',5672,'/',credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
#channel.queue_declare(queue='hello')
number = random.randint(1,1000)
body = 'hello world:%s' %number
channel.basic_publish(exchange='',
routing_key='hello',
body=body)
print " [x] Sent %s" %body
connection.close()
--结束END--
本文标题: python测试rabbitmq的消息收
本文链接: https://lsjlt.com/news/188688.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0