I created a service that its purpose is to periodically update a Couchbase bucket (via the Sync Gateway) that mobile devices will synchronise with.
It also creates/updates a local Couchbase Lite file with updated documents of the above. The purpose of this step is to capture an updated Couchbase Lite DB file that can be downloaded by new devices, so new devices don’t have to sync all the data from scratch.
The flow of information is as follows:
A - Data export of updated documents to Couchbase using the Sync Gateway API.
B- Open a local Couchbase Lite DB using the Java SDK , start a one off Pull Replication, wait for the completion and close the CBL file
C – Capture the Couchbase Lite DB file so it can be downloaded by new mobile devices.
Everything works as expected but I need to insert a delay (of a few seconds) between steps A and step B, otherwise the changes applied to the bucket in step A are not reflected in step B pull replication (as shown by the ‘event listener’);
I also validated at the end of step A using the Sync Gateway bucket changes endpoint that the last updated document version is the new version (of the same document).
Is there an API that I can use on the Sync Gateway to indicate when a new pull replication will receive the latest changes?
Some more details on steps A and B
On the Sync Gateway side
Using put Document Put API’ to create or update the exported documents (only updating Documents that changed).
On the Couchbase Lite side
#wait for replication completion and close the local Lite DB
Save the DB file so it can be downloaded by multiple mobile clients