我打算选择 RethinkDB 作为我正在构建的聊天应用程序,因为它的 changefeeds功能,但后来我发现 MongoDB 有一个看起来类似的东西,叫做 Change streams 。这两者之间最显着的区别是什么?
特别是,我在 RethinkDB 文档中看到:
Since changefeeds are unidirectional with no acknowledgement returned from clients, they cannot guarantee delivery. If you need real-time updating with delivery guarantees, consider using a model that distributes to the clients through a message broker such as RabbitMQ.
我想知道MongoDB更改流是否相同?我是否能保证每次数据更改时都能收到更新?
最佳答案
MongoDB 更改流由客户端拉取,而不是由服务器推送。
客户端会在每批更新中收到一个恢复 token ,并在向服务器请求更多更新时将该 token 传回。
但这并不能完全保证。更改流取决于副本集 oplog,因此如果客户端在请求更多数据之前等待太长时间,则恢复 token 指示的事件可能已从 oplog 中清除,并且客户端将收到一条错误,指示可能错过了更新。
关于MongoDB 变更流有保证交付吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61518430/