I want to publish Json message using rabbitmqadmin command line. How can we do that as i was reading we can send only string message in payload like below rabbitmqadmin publish exchange=default routing_key=test payload="hello, world".
But I wanted to send something like this: rabbitmqadmin publish exchange=default routing_key=test payload=file.json
How can we do this in command line?
There is not an "API" but you can do it in this way:
python rabbitmqadmin publish \
exchange=amq.default routing_key=test \
payload="$(cat myjson.json)"
I tried it:
➜ bash python rabbitmqadmin publish \
exchange=amq.default routing_key=test \
payload="$(cat myjson.json)"
Message published
this may depend on the library you're using at the other end, but to get the msg processed correctly (it was a string otherwise), I needed more:
./rabbitmqadmin publish exchange=foo routing_key=foo.bar.baz \
properties='{"content_type":"application/json"}' \
payload='{}' payload_encoding='string'
Note content_type
with an underscore.
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.