Python Rabbitmq pika.BasicProperties don';无法在消息中发送属性
我正在使用pika向rabbitmq发送消息。 我需要发送其他属性,所以我使用pika.BasicProperties,但当我在Wireshark中看到此消息时,没有添加任何属性 我的代码:Python Rabbitmq pika.BasicProperties don';无法在消息中发送属性,python,rabbitmq,pika,Python,Rabbitmq,Pika,我正在使用pika向rabbitmq发送消息。 我需要发送其他属性,所以我使用pika.BasicProperties,但当我在Wireshark中看到此消息时,没有添加任何属性 我的代码: import pika, uuid connection = pika.BlockingConnection( pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.queue_de
import pika, uuid
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='test_60', durable=True, arguments={'x-message-ttl' : 21600000})
routingKey = "test_server"
message = '{"test_int":268,"Timestamp":1610022012203}'
correlation_id = str(uuid.uuid4())
reply_to = "test_60"
message_type = "SendRequest"
channel.basic_publish(exchange='',routing_key=routingKey,
body=message,properties=pika.BasicProperties(
headers={"testId": "60"},
delivery_mode=2,
correlation_id = correlation_id,
reply_to = reply_to,
type = message_type))
print('message sent')
print(correlation_id)
在Wireshark中,这个消息看起来像这样,所以没有属性,我也不知道这个示例有什么问题
prop=pika.BasicProperties(
content_type='application/json',
content_encoding='utf-8',
标题={'key':'value'},
交付模式=1,
)
channel.basic_发布(
交换=“”,
路由_key=qname,
属性=道具,
正文=“{message:hello}”
)
用户界面:
Wireshark:
我只是想知道-你凭什么确定这是发布你的邮件的软件包?我确定,因为我只发送这一条邮件,没有其他基本的。在History中发布邮件仍然-我不相信这是检查是否发送属性的正确方法。在您附加的屏幕截图中没有消息正文-因此您可以说您也不发送正文。