@Test void testScheduleJob() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); doAnswer(invocation -> { latch.countDown(); return null; }).when(eventBus).publish(isA(EventMessage.class)); ScheduleToken token = testSubject.schedule(Duration.ofMillis(30), buildTestEvent()); assertTrue(token.toString().contains("Quartz")); assertTrue(token.toString().contains(GROUP_ID)); latch.await(1, TimeUnit.SECONDS); verify(eventBus).publish(isA(EventMessage.class)); }
@Override public ScheduleToken schedule(Instant triggerDateTime, Object event) { Assert.state(initialized, () -> "Scheduler is not yet initialized"); EventMessage eventMessage = GenericEventMessage.asEventMessage(event); String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier(); QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier); try { JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier)); scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey())); } catch (SchedulerException e) { throw new SchedulingException("An error occurred while setting a timer for a saga", e); } return tr; }
QuartzEventScheduler implements org.axonframework.eventhandling.scheduling.EventScheduler { @Override public ScheduleToken schedule(Instant triggerDateTime, Object event) { Assert.state(initialized, () -> "Scheduler is not yet initialized"); EventMessage eventMessage = GenericEventMessage.asEventMessage(event); String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier(); QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier); try { JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier)); scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey())); } catch (SchedulerException e) { throw new SchedulingException("An error occurred while setting a timer for a saga", e); } return tr; } }
QuartzEventScheduler implements org.axonframework.eventhandling.scheduling.EventScheduler { @Override public ScheduleToken schedule(Instant triggerDateTime, Object event) { Assert.state(initialized, () -> "Scheduler is not yet initialized"); EventMessage eventMessage = GenericEventMessage.asEventMessage(event); String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier(); QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier); try { JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier)); scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey())); } catch (SchedulerException e) { throw new SchedulingException("An error occurred while setting a timer for a saga", e); } return tr; } protected  QuartzEventScheduler(Builder builder); }
QuartzEventScheduler implements org.axonframework.eventhandling.scheduling.EventScheduler { @Override public ScheduleToken schedule(Instant triggerDateTime, Object event) { Assert.state(initialized, () -> "Scheduler is not yet initialized"); EventMessage eventMessage = GenericEventMessage.asEventMessage(event); String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier(); QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier); try { JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier)); scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey())); } catch (SchedulerException e) { throw new SchedulingException("An error occurred while setting a timer for a saga", e); } return tr; } protected  QuartzEventScheduler(Builder builder); static Builder builder(); @Override ScheduleToken schedule(Instant triggerDateTime, Object event); @Override ScheduleToken schedule(Duration triggerDuration, Object event); @Override void cancelSchedule(ScheduleToken scheduleToken); void setGroupIdentifier(String groupIdentifier); @Override @ShutdownHandler(phase = Phase.INBOUND_EVENT_CONNECTORS) void shutdown(); }
QuartzEventScheduler implements org.axonframework.eventhandling.scheduling.EventScheduler { @Override public ScheduleToken schedule(Instant triggerDateTime, Object event) { Assert.state(initialized, () -> "Scheduler is not yet initialized"); EventMessage eventMessage = GenericEventMessage.asEventMessage(event); String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier(); QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier); try { JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier)); scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey())); } catch (SchedulerException e) { throw new SchedulingException("An error occurred while setting a timer for a saga", e); } return tr; } protected  QuartzEventScheduler(Builder builder); static Builder builder(); @Override ScheduleToken schedule(Instant triggerDateTime, Object event); @Override ScheduleToken schedule(Duration triggerDuration, Object event); @Override void cancelSchedule(ScheduleToken scheduleToken); void setGroupIdentifier(String groupIdentifier); @Override @ShutdownHandler(phase = Phase.INBOUND_EVENT_CONNECTORS) void shutdown();  }