I'm implementing web app using spring boot and quartz to allow registered users schedule notifications. These notifications are divided into two categories: sms and email. I would like to make possibility to choose category sms or email and then list all scheduled notifications by category. User can edit already scheduled notifications, add new ones and remove choosen ones. Task seems to be very simple, but I don't know how to assign job to user and category, since when I create new job there is possibility to identify jobs by job id and group name only. See the following code snipped:
private JobDetail createJob(ScheduleEmailDto scheduleEmailDto) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("email", scheduleEmailDto.getEmail());
jobDataMap.put("subject", scheduleEmailDto.getSubject());
jobDataMap.put("body", scheduleEmailDto.getBody());
Integer userId = scheduleEmailDto.getUserId();
Integer categoryId = scheduleEmailDto.getCategoryId();
JobDetail newJob = JobBuilder.newJob(EmailJob.class)
.withIdentity(UUID.randomUUID().toString(), "group")
.usingJobData(jobDataMap)
.storeDurably()
.build();
return newJob;
}
Does anyone is able to point me how can I assign newly created job to user and category? All suggestions would be very helpful.
If you don't already, you can configure a
JDBCJobStore
, which allows to save job_details, triggers and so on in a few database tables and handle them from DB.See http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-09.html for more details.
At that point it could be easy for you to make an additional table which can link user and category to the jobs and manage them via DB.