@Test void rescheduleWithoutToken() { org.axonframework.eventhandling.scheduling.ScheduleToken token = testSubject.reschedule(null, Duration.ofDays(1), new GenericEventMessage<>("Updated", MetaData.with("updated", "true"))); assertTrue(token instanceof SimpleScheduleToken); SimpleScheduleToken simpleScheduleToken = (SimpleScheduleToken) token; assertNotNull(scheduled.get(simpleScheduleToken.getTokenId())); }
@Override public ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) { Assert.isTrue(started.get(), () -> "Cannot dispatch new events as this scheduler is being shutdown"); Assert.isTrue(scheduleToken == null || scheduleToken instanceof SimpleScheduleToken, () -> "Invalid tracking token type. Must be SimpleScheduleToken."); String token = scheduleToken == null ? "" : ((SimpleScheduleToken) scheduleToken).getTokenId(); try { String updatedScheduleToken = eventChannel().reschedule(token, Instant.now().plus(triggerDuration), toEvent(event)) .get(requestTimeout, TimeUnit.MILLISECONDS); return new SimpleScheduleToken(updatedScheduleToken); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw GrpcExceptionParser.parse(e); } catch (ExecutionException e) { throw GrpcExceptionParser.parse(e.getCause()); } catch (TimeoutException e) { throw GrpcExceptionParser.parse(e); } }
AxonServerEventScheduler implements EventScheduler { @Override public ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) { Assert.isTrue(started.get(), () -> "Cannot dispatch new events as this scheduler is being shutdown"); Assert.isTrue(scheduleToken == null || scheduleToken instanceof SimpleScheduleToken, () -> "Invalid tracking token type. Must be SimpleScheduleToken."); String token = scheduleToken == null ? "" : ((SimpleScheduleToken) scheduleToken).getTokenId(); try { String updatedScheduleToken = eventChannel().reschedule(token, Instant.now().plus(triggerDuration), toEvent(event)) .get(requestTimeout, TimeUnit.MILLISECONDS); return new SimpleScheduleToken(updatedScheduleToken); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw GrpcExceptionParser.parse(e); } catch (ExecutionException e) { throw GrpcExceptionParser.parse(e.getCause()); } catch (TimeoutException e) { throw GrpcExceptionParser.parse(e); } } }
AxonServerEventScheduler implements EventScheduler { @Override public ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) { Assert.isTrue(started.get(), () -> "Cannot dispatch new events as this scheduler is being shutdown"); Assert.isTrue(scheduleToken == null || scheduleToken instanceof SimpleScheduleToken, () -> "Invalid tracking token type. Must be SimpleScheduleToken."); String token = scheduleToken == null ? "" : ((SimpleScheduleToken) scheduleToken).getTokenId(); try { String updatedScheduleToken = eventChannel().reschedule(token, Instant.now().plus(triggerDuration), toEvent(event)) .get(requestTimeout, TimeUnit.MILLISECONDS); return new SimpleScheduleToken(updatedScheduleToken); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw GrpcExceptionParser.parse(e); } catch (ExecutionException e) { throw GrpcExceptionParser.parse(e.getCause()); } catch (TimeoutException e) { throw GrpcExceptionParser.parse(e); } } protected  AxonServerEventScheduler(Builder builder); }
AxonServerEventScheduler implements EventScheduler { @Override public ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) { Assert.isTrue(started.get(), () -> "Cannot dispatch new events as this scheduler is being shutdown"); Assert.isTrue(scheduleToken == null || scheduleToken instanceof SimpleScheduleToken, () -> "Invalid tracking token type. Must be SimpleScheduleToken."); String token = scheduleToken == null ? "" : ((SimpleScheduleToken) scheduleToken).getTokenId(); try { String updatedScheduleToken = eventChannel().reschedule(token, Instant.now().plus(triggerDuration), toEvent(event)) .get(requestTimeout, TimeUnit.MILLISECONDS); return new SimpleScheduleToken(updatedScheduleToken); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw GrpcExceptionParser.parse(e); } catch (ExecutionException e) { throw GrpcExceptionParser.parse(e.getCause()); } catch (TimeoutException e) { throw GrpcExceptionParser.parse(e); } } protected  AxonServerEventScheduler(Builder builder); static Builder builder(); @StartHandler(phase = Phase.OUTBOUND_EVENT_CONNECTORS) void start(); @ShutdownHandler(phase = Phase.OUTBOUND_EVENT_CONNECTORS) void shutdownDispatching(); @Override ScheduleToken schedule(Instant triggerDateTime, Object event); @Override ScheduleToken schedule(Duration triggerDuration, Object event); @Override void cancelSchedule(ScheduleToken scheduleToken); @Override ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event); }
AxonServerEventScheduler implements EventScheduler { @Override public ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) { Assert.isTrue(started.get(), () -> "Cannot dispatch new events as this scheduler is being shutdown"); Assert.isTrue(scheduleToken == null || scheduleToken instanceof SimpleScheduleToken, () -> "Invalid tracking token type. Must be SimpleScheduleToken."); String token = scheduleToken == null ? "" : ((SimpleScheduleToken) scheduleToken).getTokenId(); try { String updatedScheduleToken = eventChannel().reschedule(token, Instant.now().plus(triggerDuration), toEvent(event)) .get(requestTimeout, TimeUnit.MILLISECONDS); return new SimpleScheduleToken(updatedScheduleToken); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw GrpcExceptionParser.parse(e); } catch (ExecutionException e) { throw GrpcExceptionParser.parse(e.getCause()); } catch (TimeoutException e) { throw GrpcExceptionParser.parse(e); } } protected  AxonServerEventScheduler(Builder builder); static Builder builder(); @StartHandler(phase = Phase.OUTBOUND_EVENT_CONNECTORS) void start(); @ShutdownHandler(phase = Phase.OUTBOUND_EVENT_CONNECTORS) void shutdownDispatching(); @Override ScheduleToken schedule(Instant triggerDateTime, Object event); @Override ScheduleToken schedule(Duration triggerDuration, Object event); @Override void cancelSchedule(ScheduleToken scheduleToken); @Override ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event);  }