How to send JSON payload to RabbitMQ using the web plugin?

前端 未结 2 1315
面向向阳花
面向向阳花 2021-02-07 10:06

I have a RabbitMQ 3.4.2 instance with a web management plugin installed.

When I push to the message {\'operationId\': 194} to the queue using Python\'s komb

相关标签:
2条回答
  • 2021-02-07 10:42

    You need to de-serialize the output.

    import json
    payload = json.loads(payload)
    operation_id = payload['operationId']
    

    In addition {'operationId': 194} is not valid JSON. Although it looks like you use double quotes in the screenshot, but make sure you replace the single quotes with double quotes.

    Edit: So you are correct, kombu should handle this. Looking at the code it's likely that the header is case-sensitive. Change the properties header from Content-Type to content-type.

    0 讨论(0)
  • 2021-02-07 10:43

    I had to use content_type instead of content-type (an underscore instead of a hyphen).

    This is a pretty questionable design decision, because the standard everybody knows is content-type.

    0 讨论(0)
提交回复
热议问题