我想在sqs队列中发送一条普通消息,但是kombu正在添加一些其他信息。我想发送:
{"someInfo": "value"}
当我在队列中发送带有kombu的消息时,我看到以下消息(base64编码):
{"body": "message base64 encoded", "content-encoding": "utf-8", "content-type": "text/plain", "headers": {}, "properties": {"delivery_mode": 2, "delivery_info": {"exchange": "danilo-test-queue", "routing_key": "danilo-test-queue"}, "priority": 0, "body_encoding": "base64", "delivery_tag": "b444d405-6f0e-4e73-8ffc-a81cdd804aac"}}
有什么方法可以在kombu中发送普通邮件,而无需添加其他编码并将其包装到对象中。
我正在使用的代码如下:
def send_a_message(who, producer=None):
with app.producer_or_acquire(producer) as producer:
producer.publish(
{'someInfo': who},
serializer='json',
exchange=test_queue.exchange,
routing_key='routing_key',
declare=[test_queue],
retry=True,
)
print('message sent')