Hi @Aasawari
Thank you for your response and the provided code.
I attempted to run the code with the same document and modified the info.name
field. Unfortunately, I did not observe the corresponding change stream.
When I removed the line Filters.exists("updateDescription.updatedFields.info")
and ran it again, I could observe the change stream. The logs were as follows:
2024-06-23 00:15:26.854 INFO 90541 --- [ main] c.i.m.s.impl.ChangeStreamTestService : Change detected: ChangeStreamDocument{ operationType=null, resumeToken={"_data": "826676F89E000000162B042C0100296E5A1004FC26F660C34C45348AAFB9D84F4EDE0E463C6F7065726174696F6E54797065003C7570646174650046646F63756D656E744B657900463C5F6964003C31323334353600000004"}, namespace=null, destinationNamespace=null, fullDocument=Document{{info=Document{{area_name=new, type_name=bar, year=2024, description=Sample area foo with type bar}}}}, fullDocumentBeforeChange=null, documentKey=null, clusterTime=null, updateDescription=null, txnNumber=null, lsid=null, wallTime=null}
2024-06-23 00:15:26.855 INFO 90541 --- [ main] c.i.m.s.impl.ChangeStreamTestService : Detected change in 'info': {"area_name": "new", "type_name": "bar", "year": 2024, "description": "Sample area foo with type bar"}
Additionally, I noticed that your provided code includes Aggregates.project(new Document("fullDocument.info", 1))
. This seems to mean that only the info
field is printed. When I removed this line of code and ran it again, the output was as follows:
2024-06-23 00:16:00.000 INFO 90554 --- [ main] c.i.m.s.impl.ChangeStreamTestService : Change detected: ChangeStreamDocument{ operationType=update, resumeToken={"_data": "826676F8BF000000132B042C0100296E5A1004FC26F660C34C45348AAFB9D84F4EDE0E463C6F7065726174696F6E54797065003C7570646174650046646F63756D656E744B657900463C5F6964003C31323334353600000004"}, namespace=sample_mflix.testcs, destinationNamespace=null, fullDocument=Document{{_id=123456, info=Document{{area_name=foo, type_name=bar, year=2024, description=Sample area foo with type bar}}, state=1}}, fullDocumentBeforeChange=null, documentKey={"_id": "123456"}, clusterTime=Timestamp{value=7383362138342948883, seconds=1719072959, inc=19}, updateDescription=UpdateDescription{removedFields=[], updatedFields={"info.area_name": "foo"}, truncatedArrays=[], disambiguatedPaths=null}, txnNumber=null, lsid=null, wallTime=BsonDateTime{value=1719072959979}}
2024-06-23 00:16:00.008 INFO 90554 --- [ main] c.i.m.s.impl.ChangeStreamTestService : Detected change in 'info': {"area_name": "foo", "type_name": "bar", "year": 2024, "description": "Sample area foo with type bar"}
I’m not sure what causes this difference; perhaps more details are needed.
I am developing with Spring Boot and Spring Data MongoDB, using driver version 4.9.1. The MongoDB cluster is running on Atlas, version 7.0.
Finally, thank you again for your response.