/** * Schedules a deadline after the given {@code triggerDuration} with provided context. The returned * {@code scheduleId} and provided {@code deadlineName} combination can be used to cancel the scheduled deadline. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDuration A {@link Duration} describing the waiting period before handling the deadline * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @param deadlineScope A {@link ScopeDescriptor} describing the scope within which the deadline was scheduled * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Duration triggerDuration, String deadlineName, Object messageOrPayload, ScopeDescriptor deadlineScope) { String scheduleId = generateScheduleId(); schedule(triggerDuration, deadlineName, messageOrPayload, deadlineScope, scheduleId); return scheduleId; }
/** * Schedules a deadline at given {@code triggerDateTime} with provided context. The returned {@code scheduleId} and * provided {@code deadlineName} combination can be used to cancel the scheduled deadline. * <p> * The given {@code messageOrPayload} may be any object, as well as a DeadlineMessage. In the latter case, the * instance provided is the donor for the payload and {@link org.axonframework.messaging.MetaData} of the actual * deadline being used. In the former case, the given {@code messageOrPayload} will be wrapped as the payload of a * {@link DeadlineMessage}. * </p> * * @param triggerDateTime A {@link Instant} denoting the moment to trigger the deadline handling * @param deadlineName A {@link String} representing the name of the deadline to schedule * @param messageOrPayload A {@link org.axonframework.messaging.Message} or payload for a message as an * {@link Object} * @param deadlineScope A {@link ScopeDescriptor} describing the scope within which the deadline was scheduled * @return the {@code scheduleId} as a {@link String} to use when cancelling the schedule */ default String schedule(Instant triggerDateTime, String deadlineName, Object messageOrPayload, ScopeDescriptor deadlineScope) { String scheduleId = generateScheduleId(); schedule(triggerDateTime, deadlineName, messageOrPayload, deadlineScope, scheduleId); return scheduleId; }