Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with firing triggers #4

Closed
srbnyk opened this issue Mar 17, 2015 · 1 comment
Closed

Need help with firing triggers #4

srbnyk opened this issue Mar 17, 2015 · 1 comment

Comments

@srbnyk
Copy link

srbnyk commented Mar 17, 2015

Hi

I am trying to use this project to store some reminders in redis server. I am able to create the jobs and see them in redis, but the trigger I am creating is not being fired. Could you please help me with a sample, if possible?

Here is my code to initialize JobStore:

        RedisJobStore jobStore = new RedisJobStore();
        jobStore.setHost("localhost");
        jobStore.setPort(6379);
        jobStore.setThreadPoolSize(10);
        try {
            jobStore.initialize(null, null);
            JobDetail job = JobBuilder.newJob(MyTestJob.class).withIdentity("my4_test_job").storeDurably(true).usingJobData("first_name", "Saurab").usingJobData("age", 23).usingJobData("last_name", "Nayak").build();
            CronTrigger trigger = TriggerBuilder.newTrigger().forJob(job).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(22, 18).inTimeZone(TimeZone.getTimeZone("IST")).withMisfireHandlingInstructionFireAndProceed()).withIdentity("my_test_job_trigger4").withDescription("sample trigger").build();
            jobStore.storeJobAndTrigger(job, (OperableTrigger) trigger);
            System.out.println();
        } catch (ObjectAlreadyExistsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JobPersistenceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SchedulerConfigException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Here is my Job Class:

public class MyTestJob implements Job {
    private static String KEY_FIRST_NAME = "first_name";
    private static String KEY_LAST_NAME = "last_name";
    private static String KEY_AGE = "age";

    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        System.out.println(context.getJobDetail().getJobDataMap().getString(KEY_FIRST_NAME));
    }

}

I am not seeing the execute method being called. Please let me know if I have missed something here.

Thanks

@jlinn
Copy link
Owner

jlinn commented Mar 19, 2015

Typically, jobstores are configured via the quartz.properties file. Configuration options specific to the redis jobstore can be found here.

Your job creation looks correct, but Quartz jobs are not usually stored in the jobstore directly. Instead, use a scheduler, as shown here.

@srbnyk srbnyk closed this as completed Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants