_replicate db does not exists in couchDb on Android

256 Views Asked by At

I am trying to setup replication between android tablet and a system. I use CouchDbInstance object to setup replication

This is my code

 /**
     * @param builder
     * @param couchDbInstance
     * @return the @Link{ReplicationStatus} for the replication command @Link {ReplicationCommand.Builder}
     */
    private ReplicationStatus replicate(ReplicationCommand.Builder builder, CouchDbInstance couchDbInstance) {
        int retryCount = 0;
        ReplicationStatus replicationStatus = null;
        while (retryCount < REPLICTAION_RETRY_MAX) {
            replicationStatus = couchDbInstance.replicate(builder.build());
            if (replicationStatus.isOk()) {
                break;
            }
            retryCount++;
        }
        return replicationStatus;
    }

In couch logs I see POST on _replicate returns 404

We use couchbasemobile and I know its not more supported. Can I know if _replicate way of replication is not supported and should I use _replicator way of replication

1

There are 1 best solutions below

0
On

I don't know much java, so I'm guessing here, but I think you problem is misunderstanding how _replicate is used.

The documentation here explains: http://wiki.apache.org/couchdb/Replication It's not in the offical docs anymore, as I think they want people to use _replicator.

To start a continuous replication, you POST to _replicate:

{"source":"example-database","target":"target-db", "continuous": true}

In response, you get:

{"ok":true,"_local_id":"127c65ee56bcd253d9a019f5a6f84f16+continuous+create_target"}

To get the status of the replication, you GET _active_tasks. In response, for each active replication, you get:

{"ok":true,"_local_id":"127c65ee56bcd253d9a019f5a6f84f16+continuous+create_target"}

If the "_local_id" is not in _active_tasks, the replication is not happening.

I think that your problem is here:

replicationStatus = couchDbInstance.replicate(builder.build());

I don't know the libraries you're using, but this seems wrong. You should be checking _active_tasks to see if the _local_id is there. Also, you seem to be implementing continuous replication your self.

With couchbasemobile, I have found that there are some bugs with continuous replication, and it is a good idea to periodically GET _active_tasks to check if the continuous replications are still going, restarting them if they're not. But you should still use continuous replication.