简体   繁体   中英

Quartz Schduler Job data overwriting in Jobstore tables

i'm using quartz 2.2.1 and mysql for job store, for new job creation, it's overwriting table contents in mysql table with old job data. No errors.

This is my code :

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.JobDetail;

import static org.quartz.JobBuilder.newJob;
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;

public class OwnScheduler {

    public static void main(String[] args) throws InterruptedException, SchedulerException{

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        try {
            // Grab the Scheduler instance from the Factory 

            // and start it off
            scheduler.start();

            JobDetail job1 = newJob(FetchJob.class).storeDurably(true).withIdentity("test4","Group4").build();
            Trigger trigger = (Trigger) TriggerBuilder.newTrigger()
                    .withIdentity("Trigger2", "Group4").startNow()
                    .withSchedule(simpleSchedule()
                        .withIntervalInSeconds(2))
                        .build();
            Thread.sleep(90L * 10L);

            scheduler.scheduleJob(job1, (Trigger) trigger);

            scheduler.shutdown();

        } catch (Exception se) {
            se.printStackTrace();
        }
    }
}

and my properties file:

org.quartz.scheduler.instanceName = MyScheduler
org.quartz.scheduler.instanceId = NON_CLUSTERED 
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 50
org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = quartz
org.quartz.jobStore.nonManagedTXDataSource = quartz
org.quartz.dataSource.quartz.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.quartz.URL = jdbc:mysql://localhost/quartz
org.quartz.dataSource.quartz.user = root
org.quartz.dataSource.quartz.password = password

what i'm doing wrong.

for each job creation the table data overwritten by new job details. Thanks for your attention.

How are you calling this code? You have a main entry into your JVM runtime where you init Quartz, a Job and a Trigger, you schedule the job and then shutdown the scheduler. Why don't you just start schedule and exit only based on some condition?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM