/*
 * Copyright (c) 2010-2014. Axon Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.axonframework.eventhandling.scheduling;

import java.time.Duration;
import java.time.Instant;

/**
 * Interface towards a mechanism capable of scheduling the publication of events. The accuracy of the publication time
 * depends on the exact implementation used.
 *
 * @author Allard Buijze
 * @since 0.7
 */
public interface EventScheduler {

    /**
     * Schedule the given {@code event} for publication at the given {@code triggerDateTime}. The returned
     * ScheduleToken can be used to cancel the planned publication.
     * <p/>
     * The given {@code event} may be any object, as well as an EventMessage. In the latter case, the instance
     * provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case,
     * the given {@code event} will be wrapped as the payload of an EventMessage.
     *
     * @param triggerDateTime The moment to trigger publication of the event
     * @param event           The event to publish
     * @return the token to use when cancelling the schedule
     */
    ScheduleToken schedule(Instant triggerDateTime, Object event);

    /**
     * Schedule the given {@code event} for publication after the given {@code triggerDuration}.  The
     * returned ScheduleToken can be used to cancel the planned publication.
     * <p/>
     * The given {@code event} may be any object, as well as an EventMessage. In the latter case, the instance
     * provided is the donor for the payload and Meta Data of the actual message being dispatched. In the former case,
     * the given {@code event} will be wrapped as the payload of an EventMessage.
     *
     * @param triggerDuration The amount of time to wait before publishing the event
     * @param event           The event to publish
     * @return the token to use when cancelling the schedule
     */
    ScheduleToken schedule(Duration triggerDuration, Object event);

    /**
     * Cancel the publication of a scheduled event. If the events has already been published, this method does nothing.
     *
     * @param scheduleToken the token returned when the event was scheduled
     * @throws IllegalArgumentException if the token belongs to another scheduler
     */
    void cancelSchedule(ScheduleToken scheduleToken);
}

@@ -2883,11 +2883,852 @@
 eToken);
+%0A%0A    /**%0A     * Cancel a scheduled event and schedule another in its place.%0A     * %3Cp/%3E%0A     * Convenience method around %7B@link #cancelSchedule(ScheduleToken)%7D and %7B@link #schedule(Duration, Object)%7D.%0A     *%0A     * @param scheduleToken   the token returned when the event was scheduled, might be null%0A     * @param triggerDuration The amount of time to wait before publishing the event%0A     * @param event           The event to publish%0A     * @throws IllegalArgumentException if the token belongs to another scheduler%0A     * @return the token to use when cancelling the schedule%0A     */%0A    default ScheduleToken reschedule(ScheduleToken scheduleToken, Duration triggerDuration, Object event) %7B%0A        if (null != scheduleToken) %7B%0A            cancelSchedule(scheduleToken);%0A        %7D%0A        return schedule(triggerDuration, event);%0A    %7D
 %0A%7D%0A

Add convenience reschedule method on EventScheduler