Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

MongoDB 3.6 Change Streams Node Sample

MongoDB 3.6 cluster configuration

You must configure a replica set for change streams to work. Follow the instructions below:

  1. Make sure the latest version of mtools is installed on your machine
  2. Edit setup.sh and update the MONGODB_LOCATION variable to point to your local MongoDB 3.6 installation root
  3. Run sh setup.sh to set up your MongoDB 3.6 replica set using mlaunch
  4. Run sh run.sh to start your MongoDB 3.6 replica

Node application configuration

  1. Run npm install to install the required Node dependencies
  2. Run node produce.js to create the demo database, the devices collection and a first document.
  3. Run node listen.js to start listening to change streams coming from the devices collection of the demo database.
  4. In a separate Terminal window, run node produce.js again - this will add a document to the devices collection of the demo database.
  5. Look at the window running listen.js and if everything was properly configured you should get a Change Stream log message, followed by a waiting for change stream... message.
  6. Now stop the listen.js process. We're simulating an application crash and the ability to resume processing MongoDB Change Streams from the exact time the application "crashed".
  7. Add a few documents by running node produce.js several times.
  8. Start node listen.js again and notice that the previous documents you just added get processed right away.

About

MongoDB 3.6 Node Change Streams Sample

Topics

Resources

License

Releases

No releases published

Packages

No packages published