More than 2 instances are running on different port hitting same database(Oracle) using SchedLock

143 Views Asked by At

I am using spring scheduler to send email in every 10 minutes, In which i want to deploy application in different server, so i have used shedLock to prevent multiple email at the same time, i followed documentation https://github.com/lukas-krecan/ShedLock

code i have used is this.

@Scheduled(fixedRate = 900000)
    @SchedulerLock(name = "scheduledTaskName",lockAtLeastForString = "PT5M", lockAtMostForString = "PT14M")
    public void scheduleTaskWithFixedRate() {

        log.error("Fixed Rate Task Thread start:: Execution Time - {}"+LocalDateTime.now()+" "+Thread.currentThread().getName());
        try {
            //10 sec
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        log.error("Fixed Rate Task Thread End:: Execution Time - {}"+LocalDateTime.now()+" "+Thread.currentThread().getName());

    }

can anyone help in this?

0

There are 0 best solutions below