nodejs 有哪些好的消息队列选项?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4700935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 13:49:18  来源:igfitidea点击:

What are good message queue options for nodejs?

node.jsmessage-queue

提问by Bjorn

Looking to use a message queue in a small web app I'm building with node.js. I looked at resque but not sure that's appropriate. The goal is to push notifications to clients based on backend and other client actions with socketio. I could do this with just socketio but I thought maybe a proper message queue would make this cleaner and I wouldn't have to reinvent the wheel.

希望在我使用 node.js 构建的小型 Web 应用程序中使用消息队列。我查看了 resque,但不确定这是否合适。目标是使用 socketio 根据后端和其他客户端操作向客户端推送通知。我可以只用 socketio 来做到这一点,但我想也许一个合适的消息队列会让这个更干净,我不必重新发明轮子。

What are the options out there?

有哪些选择?

采纳答案by Alfred

you could use rediswith the lightning fast node_redisclient. It even has built-in pubsubsemantics.

您可以将redis与闪电般快速的node_redis客户端一起使用。它甚至具有内置的pubsub语义。

回答by James Cooper

You could use the node STOMP client. This would let you integrate with a variety of message queues including:

您可以使用节点STOMP 客户端。这将使您能够与各种消息队列集成,包括:

  • ActiveMQ
  • RabbitMQ
  • HornetQ
  • ActiveMQ
  • 兔MQ
  • 大黄蜂Q

I haven't used this library before, so I can't vouch for its quality. But STOMP is a pretty simple protocol so I suspect you can hack it into submission if necessary.

我以前没有使用过这个库,所以我不能保证它的质量。但是 STOMP 是一个非常简单的协议,因此我怀疑您可以在必要时将其修改为提交。

Another option is to use beanstalkd with node. beanstalkd is a very fast "task queue" written in C that is very good if you don't need the feature flexibility of the brokers listed above.

另一种选择是将beanstalkd 与 node一起使用。beanstalkd 是一个用 C 编写的非常快速的“任务队列”,如果您不需要上面列出的代理的功能灵活性,它非常好。

回答by Josh Bassett

Shameless plug: I'm working on Bokeh: a simple, scalable and blazing-fast task queue built on ZeroMQ. It supports pluggable data stores for persisting tasks, currently in-memory, Redis and Riak are supported. Check it out.

无耻的插件:我正在研究Bokeh:一个基于 ZeroMQ 的简单、可扩展且速度极快的任务队列。它支持用于持久化任务的可插拔数据存储,目前支持内存中、Redis 和 Riak。一探究竟。

回答by RobotEyes

Here's a couple of recommendations I can make:

我可以提出以下几点建议:

node-amqp: A RabbitMQ client that I have successfully used in combination with Socket.IO to make a real-time multi-player game and chat application amongst other things. Seems reliable enough.

node-amqp:一个 RabbitMQ 客户端,我已经成功地将它与 Socket.IO 结合使用来制作实时多人游戏和聊天应用程序等。看起来足够可靠。

zeromq.node: If you want to go down the non-brokered route this might be worth a look. More work to implement functionality but your more likely to get lower latency and higher throughput.

zeromq.node:如果您想沿着非代理路线走下去,这可能值得一看。实现功能需要更多的工作,但您更有可能获得更低的延迟和更高的吞吐量。

回答by fujifish

Take a look at node-busmq- it's a production grade, highly available and scalable message bus backed by redis.

看看node-busmq- 它是由 redis 支持的生产级、高度可用和可扩展的消息总线。

I wrote this module for our global cloud and it's currently deployed in our production environment in several datacenters around the world. It supports named queues, peer-to-peer communication, guaranteed delivery and federation.

我为我们的全球云编写了这个模块,它目前部署在我们全球多个数据中心的生产环境中。它支持命名队列、对等通信、保证交付和联合。

For more information on why we created this module you can read this blog post: All Aboard The Message Bus

有关我们创建此模块的原因的更多信息,您可以阅读此博客文章:All Aboard The Message Bus

回答by Pono

kueis the only message queue you would ever need

kue是您唯一需要的消息队列

回答by Eduardo Raad

I recommend trying Kestrel, it's fast and simple as Beanstalk but supports fanout queues. Speaks memcached. It's built using Scala and used at Twitter.

我建议尝试Kestrel,它像 Beanstalk 一样快速而简单,但支持扇出队列。说到memcached。它使用 Scala 构建并在 Twitter 上使用。

回答by Smrchy

You might want to have a look at

你可能想看看

Redis Simple Message Queue for Node.js

Node.js 的 Redis 简单消息队列

Which uses Redis and offers most features of Amazons SQS.

它使用 Redis 并提供 Amazon SQS 的大部分功能。

回答by Ben

How about Azure ServiceBus? It supports nodejs.

Azure ServiceBus 怎么样?它支持 nodejs。

回答by Brian McAuliffe

I used KUE with socketIO like you described. I stored the socketID with the job and could then retreive it in the Job Complete.. KUE is based on redis and has good examples on github

我像你描述的那样将 KUE 与 socketIO 一起使用。我将 socketID 与作业一起存储,然后可以在作业完成中检索它.. KUE 基于 redis 并且在 github上有很好的例子

something like this....

像这样的东西....

jobs.process('YourQueuedJob',10, function(job, done){
    doTheJob(job, done);
});


function doTheJob(job, done){
    var socket = io.sockets.sockets[job.data.socketId];
    try {
        socket.emit('news', { status : 'completed' , task : job.data.task });
    } catch(err){
        io.sockets.emit('news', { status : 'fail' , task : job.data.task , socketId: job.data.socketId});
    }
    job.complete();
}
jobs.process('YourQueuedJob',10, function(job, done){
    doTheJob(job, done);
});


function doTheJob(job, done){
    var socket = io.sockets.sockets[job.data.socketId];
    try {
        socket.emit('news', { status : 'completed' , task : job.data.task });
    } catch(err){
        io.sockets.emit('news', { status : 'fail' , task : job.data.task , socketId: job.data.socketId});
    }
    job.complete();
}