python - Rabbitmq pika.BasicProperties 不在消息中发送属性
问题描述
我正在使用 pika 向 rabbitmq 发送消息。我需要发送其他属性,所以我使用 pika.BasicProperties,但是当我在 Wireshark 中看到此消息时,没有添加任何属性。
我的代码:
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 中,这条消息看起来像这样,所以没有属性,我不知道这个例子有什么问题。
解决方案
推荐阅读
- sql - sql Oracle中的时差
- c# - 缺少迁移的单元测试
- python - 来自dict理解的Python类变量引用子类
- switch-statement - Swift - 如何检查开关盒是否包含值
- loops - 如何在汇编中制作 2 个 8 位数字的 pow
- css - 页面左侧的 Facebook iframe
- typescript - 如何解决打字稿错误“可能未定义的对象”?- ts(2532)
- javascript - 如何通过注册推送传入的详细信息以登录到javascript中的本地存储
- html - 有什么方法可以避免在 WAVE 辅助工具上出现这个警告(文本太小),但保持字体大小不变?
- css - SCSS 辅助类 @mixin 带有破折号问题