Publishing single messages to a RabbitMQ queue can be easily done with the UI, by simply putting the message in the UI and clicking the "Publish Message" button.
How do you publish a batch of messages?
I have a file with messages to be sent to RabbitMQ. Each line has one message.
How can I publish all the messages from the file to my RabbitMQ server?
Is there a way to do it from command line?
It is possible to manually publish a message to the queue from "publish message". The message will be published to the default exchange with the queue name as given routing key - meaning that the message will be sent to the queue. It is also possible to publish a message to an exchange from the exchange view.
Queues are single-threaded in RabbitMQ, and one queue can handle up to about 50 thousand messages. You will achieve better throughput on a multi-core system if you have multiple queues and consumers and if you have as many queues as cores on the underlying node(s).
Using rabbitmqadmin
while read -r line; do
echo $line | rabbitmqadmin publish exchange=amq.default routing_key=my_queue ;
done < messages
Not specifying the payload parameter to rabbitmqadmin publish
means it reads the payload from stdin.
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