是什么最佳方法来调查MongoDB数据库寻找更改
我有两个微服务(Servicea和ServiceB)。
- Servicea将记录插入到MongoDB数据库中。
- ServiceB在MongoDB中检查是否有新记录,并且对这些新记录进行了一些工作。
ServiceB是一个背景服务,在executeasync
方法中,我查询MongoDB每秒检查新记录。
是每秒查询数据库的好方法吗? (这不是资源密集型吗?它是一个有条件的选择)
,否则,我正在考虑使用兔子:
- servicea inserts记录在mongodb数据库中,然后将消息(记录的ID)推向兔子。
- ServiceB消耗RabbitMQ的消息并确实有效。
I have two microservices (ServiceA and ServiceB).
- ServiceA inserts records into a MongoDB database.
- ServiceB check in MongoDB if there are new records and does some work with theses new records.
ServiceB is a backgroundservice, in ExecuteAsync
method, I query MongoDB to check new records every second.
Is it a good approach to query the database every second? (Is it not too resource intensive? It's a select with where condition)
Otherwise, I was thinking of using RabbitMQ:
- ServiceA inserts records in MongoDB database and pushes message (Id of record) to RabbitMQ.
- ServiceB consumes RabbitMQ's message and does work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论