Skip to content

antlen/mongo-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo-utils

A utility for subscribing to a mongo collction for updates whenever there is an insert, update or delete.

	<dependency>
	   <groupId>org.estonlabs</groupId>
	  <artifactId>mongo-utils</artifactId>
	  <version>1.0.0</version>
    </dependency>
	 final MongoClient mongoClient = new MongoClient("localhost" , 3001 );	
     final OplogMonitor mongo = new OplogMonitor(mongoClient);
     mongo.start();
	
	 final Namespace namespace = new Namespace( "meteor", "markets" );		

	//only listen to the insert and delete events.  
	mongo.listenToNameSpace(namespace, this, OplogEventType.INSERT, OplogEventType.DELETE);
 
 
 	  //sometime later when finished monitoring call
      mongo.stop();