简体   繁体   中英

Rabbitmq pika.BasicProperties don't send properties in message

I'm using pika to send message to rabbitmq. I need to send additional properties so I'm using pika.BasicProperties, but when I see this message in Wireshark there are no properties added.

My code:

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)

In Wireshark this message looks like this, so there are no properties and I have no idea what is wrong with this example.

在此处输入图像描述

 prop = pika.BasicProperties(
            content_type='application/json',
            content_encoding='utf-8',
            headers={'key': 'value'},
            delivery_mode = 1,
        )

        channel.basic_publish(
                exchange='',
                routing_key=qname,
                properties=prop,
                body='{message: hello}'
            )

UI:

在此处输入图像描述

Wireshark:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM