Class JobRunrEventScheduler

java.lang.Object
org.axonframework.eventhandling.scheduling.jobrunr.JobRunrEventScheduler
All Implemented Interfaces:
EventScheduler, Lifecycle

public class JobRunrEventScheduler extends Object implements EventScheduler, Lifecycle
EventScheduler implementation that delegates scheduling and triggering to a JobRunr JobScheduler.
Since:
4.7.0
Author:
Gerard Klijs
  • Constructor Details

  • Method Details

    • builder

      public static JobRunrEventScheduler.Builder builder()
      Instantiate a Builder to be able to create a JobRunrEventScheduler.

      The TransactionManager is defaulted to a NoTransactionManager.

      The JobScheduler, Serializer and EventBus are hard requirements and as such should be provided.

      Returns:
      a Builder to be able to create a JobRunrEventScheduler
    • schedule

      public ScheduleToken schedule(Instant triggerDateTime, Object event)
      Description copied from interface: EventScheduler
      Schedule the given event for publication at the given triggerDateTime. The returned ScheduleToken can be used to cancel the planned publication.

      The given 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 event will be wrapped as the payload of an EventMessage.

      Specified by:
      schedule in interface EventScheduler
      Parameters:
      triggerDateTime - The moment to trigger publication of the event
      event - The event to publish
      Returns:
      the token to use when cancelling the schedule
    • schedule

      public ScheduleToken schedule(Duration triggerDuration, Object event)
      Description copied from interface: EventScheduler
      Schedule the given event for publication after the given triggerDuration. The returned ScheduleToken can be used to cancel the planned publication.

      The given 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 event will be wrapped as the payload of an EventMessage.

      Specified by:
      schedule in interface EventScheduler
      Parameters:
      triggerDuration - The amount of time to wait before publishing the event
      event - The event to publish
      Returns:
      the token to use when cancelling the schedule
    • cancelSchedule

      public void cancelSchedule(ScheduleToken scheduleToken)
      Description copied from interface: EventScheduler
      Cancel the publication of a scheduled event. If the events has already been published, this method does nothing.
      Specified by:
      cancelSchedule in interface EventScheduler
      Parameters:
      scheduleToken - the token returned when the event was scheduled
    • shutdown

      public void shutdown()
      Description copied from interface: EventScheduler
      Shuts down this event scheduler.
      Specified by:
      shutdown in interface EventScheduler
    • registerLifecycleHandlers

      public void registerLifecycleHandlers(@Nonnull Lifecycle.LifecycleRegistry lifecycle)
      Description copied from interface: Lifecycle
      Registers the activities to be executed in the various phases of an application's lifecycle. This could either be at startup, shutdown, or both.
      Specified by:
      registerLifecycleHandlers in interface Lifecycle
      Parameters:
      lifecycle - the lifecycle instance to register the handlers with
      See Also:
    • publish

      public void publish(String serializedPayload, String payloadClass)
      This function should only be called via Jobrunr when a scheduled event was triggered. It will create an EventMessage and publish it using the EventBus.
      Parameters:
      serializedPayload - The String with the serialized payload.
      payloadClass - The String with the name of the class ot the payload.
    • publish

      public void publish(String serializedPayload, String payloadClass, String serializedMetadata)
      This function should only be called via Jobrunr when a scheduled event was triggered. It will create an EventMessage and publish it using the EventBus.
      Parameters:
      serializedPayload - The String with the serialized payload.
      payloadClass - The String with the name of the class of the payload.
      serializedMetadata - The String with the serialized metadata.
    • publishWithRevision

      public void publishWithRevision(String serializedPayload, String payloadClass, String revision)
      This function should only be called via Jobrunr when a scheduled event was triggered. It will create an EventMessage and publish it using the EventBus.
      Parameters:
      serializedPayload - The String with the serialized payload.
      payloadClass - The String with the name of the class ot the payload.
      revision - The String with the revision of the class of the payload. Might be null.
    • publishWithRevision

      public void publishWithRevision(String serializedPayload, String payloadClass, String revision, String serializedMetadata)
      This function should only be called via Jobrunr when a scheduled event was triggered. It will create an EventMessage and publish it using the EventBus.
      Parameters:
      serializedPayload - The String with the serialized payload.
      payloadClass - The String with the name of the class of the payload.
      revision - The String with the revision of the class of the payload. Might be null.
      serializedMetadata - The String with the serialized metadata.