• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Callback when Document is Stored in Mongo

 
Sangel Kapoor
Ranch Hand
Posts: 157
1
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JAVA to talk to MONGO DB,

I am interested in getting the callback from MongoDB when a Document is stored successfully on the Mongo.

I want to get this callback so that I can broadcast the success message to the Listeners.

 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you need to look at Write Concern in MongoDB. This is basically a setting that decides when/if MongoDB confirms that a document has been written successfully or how it reports any errors. MongoDB is designed to support robust horizontal scaling across multiple machines via sharding and replication, and data gets written first to memory, then to the actual database and replicas. There are different levels of write concern depending on how much of a guarantee you want that your data has definitely been written to the database and replicated across all servers, so you would choose the write concern that suits your application's requirements. The default is Acknowledged.

One common practice on a replicated cluster is to write to one machine (the master) but read from several replicated workers, so it may take a few moments before your workers receive the latest update from the master, for example. A very strict write concern may influence application performance on a replicated cluster, because your application may have to wait for all replicated nodes to respond before it can continue after the write operation. This might be a reason to explore asynchronous processing, for example.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic