Company
Date Published
Author
MongoDB
Word count
550
Language
English
Hacker News points
None

Summary

Using MongoDB's capped collections and tailable cursors, developers can build a simple pub/sub system to communicate messages between processes. This allows for efficient retrieval of records from the server until some data becomes available, blocking until data is returned by the cursor. The use of tailed cursors offers a more efficient solution than constantly re-querying for new data. A basic example using Node.js demonstrates this functionality, where a subscriber can repeatedly poll the cursor for any new messages. This setup provides a powerful feature for performing complex queries and is a minimal effort alternative to existing messaging systems.