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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With