简体   繁体   中英

Node.js queue with long polling


I am looking for a library for Node.js to implement queue.
Basicaly I have a cloud system with two different REST APIs:

  1. Receive inputs and write a message on a queue identified with an ID.
  2. The second one is more tricky: this endpoint is called from an external client in long polling. So this API will try to read from a queue and wait untill a message arrive in the queue. Of course this endpoint has a timeout, so after 30 seconds if no message has arrived in the queue, send a response.

How can I do this in Node.js? Any suggestions? There are a lot of libraries for Node.js but I don't know which is better to use in this case.

Thanks a lot for your help!

I suggest you looking at this library https://github.com/Automattic/kue . It's based on redis and it's really easy to learn. Kue has a lot of features like ttl, admin, attempt, ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM