michaelklishin / quartz-mongodb

A MongoDB-based store for the Quartz scheduler. This fork strives to be as feature complete as possible. Originally by MuleSoft.
Other
249 stars 203 forks source link

JobData added to Trigger not passed to Job Instance #143

Closed zeeshan-v1 closed 7 years ago

zeeshan-v1 commented 7 years ago

http://stackoverflow.com/q/42025607/3148412

I have a durable job added to the scheduler. At the runtime, i am building a trigger using below code:

Trigger trigger = TriggerBuilder.newTrigger()
                    .withIdentity(new TriggerKey(triggerKey))
                    .forJob(Constants.CAMPAIGN_MAILING_JOB_KEY)
                    .usingJobData("test", "test")
                    .startAt(new Date(runTime))
                    .build();

I then schedule this job using ,

scheduler.scheduleJob(trigger); The job is executed properly, however the Jobdata ("test" string param) is giving me null in the job. this is my job code,

public class CampaignMessageSendingJob implements Job{
public String campaignId;
public String messageId;

@Override
public void execute(JobExecutionContext jobContext) throws JobExecutionException {
    System.out.println("This JOb Was called at"+System.currentTimeMillis());

    JobKey key = jobContext.getJobDetail().getKey();
    JobDataMap map= jobContext.getMergedJobDataMap();
    System.out.println(map.getString("test")); //This is printing NULL

}

public String getCampaignId() {
    return campaignId;
}

public void setCampaignId(String campaignId) {
    this.campaignId = campaignId;
}

public String getMessageId() {
    return messageId;
}

public void setMessageId(String messageId) {
    this.messageId = messageId;
}
}
michaelklishin commented 7 years ago

Can this be reproduced with another Quartz store? So far there is no evidence that it is an issue in the store.

zeeshan-v1 commented 7 years ago

I havent checked with Quartz RamJobStore yet, will do and update. One thing i wanted to mention is i havent added below line in props- is that going to cause an issue? org.quartz.jobStore.jobDataAsBase64=false

zeeshan-v1 commented 7 years ago

I also tried the Job with Non-Durability as well, the issue persists. Whatever i add with usingJobData on Trigger is not being transferred to Job Instance

zeeshan-v1 commented 7 years ago

@michaelklishin i verified this.. with Ram Store its working perfectly fine. However as i add ,mongodb store, the trigger Job data becomes null. Here is my quartz property file and i am using quartz-mongodb-2.0.0-rc2.jar

org.quartz.jobStore.class=com.novemberain.quartz.mongodb.MongoDBJobStore org.quartz.jobStore.mongoUri=mongodb://localhost:27017 org.quartz.jobStore.dbName=mailemergencydb2 org.quartz.jobStore.collectionPrefix=mailemergency org.quartz.threadPool.threadCount=1 org.quartz.scheduler.instanceName = MailEmergencyJobScheduler org.quartz.scheduler.skipUpdateCheck=true

zeeshan-v1 commented 7 years ago

FIXED by using correct version of Jar. I was using quartz-mongodb-2.0.0-rc2.jar where as i should have been using quartz-mongodb-2.0.0.jar