I was trying to use MongoDB change stream. I was not able to do that because Spring Boot 1.5.10.RELEASE uses MongoDB driver version 3.4.
When I upgrade the Mongo Driver version to 3.6.3 than I am able to use MongoDB change streams.
<mongodb.version>3.6.2</mongodb.version>
Change stream related classes are not available in Mongo Driver version 3.4.
Bug report
MongoClient mongoClient = context.getBean(MongoClient.class);
KafkaSkuMessageProducer kafkaSkuMessageProducer = context.getBean(KafkaSkuMessageProducer.class);
MongoDatabase database = mongoClient.getDatabase("test");
MongoCollection<Document> myCollection = database.getCollection("mycollection");
MongoCursor<ChangeStreamDocument<Document>> cursorIterator = myCollection.watch().fullDocument(FullDocument.UPDATE_LOOKUP).iterator();
The problem is that watch method is not there in older version 3.4 of MongoDB Java Driver.
Enhancement
Solution is to upgrade the version number of MongoDB java driver.
<mongodb.version>3.6.3</mongodb.version>
or Update to any more current MongoDB Java Driver version.
Comment From: wilkinsona
Duplicate of #12055.
Comment From: icewheel
@wilkinsona For Spring Boot 1.x. Will it be upgraded also?
Comment From: philwebb
@icewheel We only upgrade to patch releases, so only mongo 3.4.x will be considered.
Comment From: VenkatTM
Is Spring Boot 1.5.9.RELEASE will support mongo 3.6
Comment From: bclozel
@VenkatTM Spring Boot 1.5.x has been EOL for a few years now, please consider upgrading to a supported version.