@Override
    public int incRepeatedCount(String jobId) {
        while (true) {
            JobPo jobPo = getJob(jobId);
            if (jobPo == null) {
                return -1;
            }
            Query<JobPo> query = template.createQuery(JobPo.class);
            query.field("jobId").equal(jobId);
            query.field("repeatedCount").equal(jobPo.getRepeatedCount());

            UpdateOperations<JobPo> opts = template.createUpdateOperations(JobPo.class);
            opts.set("repeatedCount", jobPo.getRepeatedCount() + 1);

            UpdateResults ur = template.update(query, opts);
            if (ur.getUpdatedCount() == 1) {
                return jobPo.getRepeatedCount() + 1;
            }
        }
    }
@author Robert HG (254963746@qq.com) on 3/26/16.
lts-core/src/main/java/com/github/ltsopensource/queue/mongo/MongoRepeatJobQueue.java