Я расширил класс JdbcMessageIdRepository и переопределил queryforInt
public class FuseJDBCMessageIdRepository extends JdbcMessageIdRepository {
public FuseJDBCMessageIdRepository() {
}
public FuseJDBCMessageIdRepository(DataSource dataSource, String processorName) {
super(dataSource, processorName);
}
public FuseJDBCMessageIdRepository(DataSource dataSource, TransactionTemplate transactionTemplate, String processorName) {
super(dataSource, transactionTemplate, processorName);
}
public FuseJDBCMessageIdRepository(JdbcTemplate jdbcTemplate, TransactionTemplate transactionTemplate) {
super(jdbcTemplate, transactionTemplate);
}
@Override
public int queryForInt(String key) {
int value = super.queryForInt(key);
if (value == 0 && insert(key) >0){
return value;
}
return value;
}
@Override
public int insert(String key) {
return super.insert(key);
}
@Override
public int delete(String key) {
return super.delete(key);
}
}