How could I send array of messages using RabbitMQ? I do not want to send every message separately.
You can't. Each message must be sent individually.
If you tried to do what you want, you would end up with a single "message" that contained all of the individual messages you wanted to send.
If you want to make an API that looks like you can do this, just create a function that takes an array of messages, loops through them and sends them one at a time.
(nodejs / amqplib)
function publishAll(ex, ...messages){
return messages.map((msg) => {
ch.publish(ex, '', msg);
});
}
var pub = publishAll("my.exchange", [msg1, msg2, msg3]);
pub.then(() => {
// run code after they are all published
});