0

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.
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Julien Martin
  • 197
  • 2
  • 15

0 Answers0