Streaming new records

26 views
Skip to first unread message

Boas Enkler

unread,
Jul 25, 2017, 5:59:01 AM7/25/17
to mongodb-user
in a mongodatabase i've a collection with logentries . they entries are pushed there very constantly. 
on the ui side i want to show some kind of live log.

For this i currently poll every 500ms the database and show the new entries.

As this is quite inperformant i would like to stream new records or at least get notficiations when new records are inserted in the collection.

Is there a better way then just polling them?

Wan Bachtiar

unread,
Aug 6, 2017, 10:06:37 PM8/6/17
to mongodb-user

Is there a better way then just polling them?

Hi Boas,
You could use tailable cursors on MongoDB’s OpLog for Publish-Subscribe type of data flow.
See also Blog: Tailing the MongoDB OpLog on Sharded Clusters for more information.

Alternatively, depending on your use case see MongoDB Stitch Push Notifications Services.
Also worth mentioning that in the upcoming MongoDB v3.6 there will be a new event notification API, see Blog: New Driver Features for MongoDB 3.6

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages