As document(https://docs.mongodb.com/manual/changeStreams/) says, we can resume to get event from MongoDB using resumeToken.
I will store recent resumeToken to common storage, but I'm not sure whether this resume token is unique globally or not. I want to know it's unique for whole collections or each collection.
It seems to use UUID (https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/resume_token.h#L61)..
Thanks
The resumeToken
is unique within a single MongoDB deployment cluster. MongoDB change streams utilise a global logical clock. The server encodes the cluster time as the prefix value of a resumeToken
, resulting in change streams notifications can be safely interpreted in the order received.
Starting from MongoDB v4.0, you can open a change stream cursor for a deployment to watch for changes to all non-system collections across all databases except for admin
, local
, and config
.