gpt4 book ai didi

node.js - 通过 RabbitMQ 发送数组

转载 作者:太空宇宙 更新时间:2023-11-03 22:14:47 24 4
gpt4 key购买 nike

如何使用 RabbitMQ 发送消息数组?我不想单独发送每条消息。

例如:

ch.publish(ex, '', new Buffer('hello world'));

我怎样才能使用类似的东西:

ch.publish(ex, '', new Buffer([msg1, msg2, msg3...]));

谢谢!

最佳答案

您可以像这样传递 JSON:

var json = JSON.stringify(arr);
ch.publish(ex, '', new Buffer(json));

然后消费者将解析 JSON。

关于node.js - 通过 RabbitMQ 发送数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32586219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com