Removing Records from shedlock table which is managed by spring itself i want to remove records from shedlock table?

101 views Asked by At

I have try removing like this this works correctly but the new records weren't inserted until application start.

package com.jcdecaux.hive.refproxy.dao.db.repository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ShedLockRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void deleteAllShedlockRecords() {
        String deleteQuery = "TRUNCATE TABLE shedlock";
        jdbcTemplate.update(deleteQuery);
    }


}

I want to remove records from database but with correct functionality is there any way to do this from shedlock library or any recommended approach exits to do this ?

1

There are 1 answers

2
Lukas On

There is no way how to do that using ShedLock as it is not safe to do it. Your code looks OK, you just need to delete the records and clean the cache using this method. For tests it's OK, doing this in production can lead to multiple tasks being executed.