随着MongoDB的,是通过.NET无扩展(RX),能够接收第三方修改的通知?第三方、通知、MongoDB、NET

2023-09-06 10:58:04 作者:瘾男

我不知道是否有人知道,如果它可能得到的任何编辑通过无扩展MongoDB数据库(RX)现场通知在C#?

I'm wondering if anybody knows if its possible to get live notifications of any edits to a MongoDB database via Reactive Extensions (RX) in C#?

这意味着任何第三方可以编辑的MongoDB数据库和服务可以监测的编辑,并立即进行实时作出反应。

This would mean that any 3rd party could edit the MongoDB database, and a service could monitor the edits and instantly react to them in real time.

我已经试过

我花了大量的时间对谷歌和其他地方的研究这一点,并已通过所有可能相关的NuGet包。唯一的比赛,我能找到参与Java的,并且是在德国。

I have spent a large amount of time researching this on both Google and elsewhere, and been through all of the NuGet packages that might be related. The only match I could find involved Java, and was in German.

更新1

看着tailable光标,在这里:

Looking at tailable cursors, here:

http://www.warski.org/blog / 2012/11 /事件流与 - 的MongoDB /

推荐答案

我不知道具体的反应扩展的实现,但是一般的方法(如在MongoDB的2.6)将是的创建一个封顶集合tailable光标 - 在你提到的德国博客文章采取了同样的做法

How to track 3rd party changes to MongoDB data

I'm not aware of a specific Reactive Extensions implementation, however the general approach (as at MongoDB 2.6) would be to create a tailable cursor on a capped collection -- the same approach taken in the German blog post you referenced.

通过对复制OPLOG 你会得到一个tailable光标在所有数据库的变化,您可以通过命名空间和操作过滤流(插入,删除,更新)为适当。

With a tailable cursor on the replication oplog you will get a stream of changes across all databases that you can filter by namespace and operation (insert, delete, update) as appropriate.

在一个OPLOG通常仅用于复制的目的而创建,如果你有一个独立的MongoDB服务器还可以运行它作为一个节点副本设置唯一的好处是在 OPLOG 的

While an oplog is normally only created for the purposes of replication, if you have a standalone MongoDB server you can also run it as a single node replica set with the sole benefit being the oplog.

默认情况下, OPLOG大小上64位系统(除OS X)将可用磁盘空间的5%。您可以使用 oplogSize 配置参数指定不同的OPLOG大小。如果你不打算使用复制,你也许可以减少OPLOG大小的东西更适合您的更改通知。如果你不知道在合适的尺寸,我会离开,在默认的,后来按照教程来的如果需要更改OPLOG大小。

By default, the oplog size on 64-bit systems (excepting OS X) will be 5% of free disk space. You can use the oplogSize configuration parameter to specify a different oplog size. If you don't intend to use replication, you can probably reduce the oplog size to something more suitable for your change notification. If you're not sure on an appropriate size, I would leave at the default and later follow the tutorial to Change the Oplog Size if needed.

要转换的独立服务器成为一个单节点副本设定,你基本上需要:

To convert your standalone server into a single node replica set you essentially need to:

添加 复制集 配置值(和可选, oplogSize 如果你想要一个初始大小不同于默认) 重新启动您的MongoDB服务器,使此更改生效 作为一个曾经关闭的蒙戈外壳,运行的 rs.initiate() 创建副本集的配置和preallocate的OPLOG Add a replSet configuration value with a unique name for your replica set (and optionally, oplogSize if you want an initial size different from the default) Restart your MongoDB server so this change takes effect As a once off in the mongo shell, run rs.initiate() to create the replica set configuration and preallocate the oplog