Class Schedule

java.lang.Object
io.fluxcapacitor.javaclient.common.Message
io.fluxcapacitor.javaclient.scheduling.Schedule
All Implemented Interfaces:
HasMetadata, HasMessage

public class Schedule extends Message
Represents a scheduled message to be delivered at a specific future time.

Schedule extends Message with a scheduleId and a deadline indicating when the message should be delivered.

It supports transformation and enrichment just like a regular Message, and includes convenience methods for rescheduling.

Typical Usage


 new Schedule(new Reminder("water the plants"), Duration.ofHours(1));
 
See Also:
  • Field Details

    • scheduleIdMetadataKey

      public static String scheduleIdMetadataKey
      Metadata key for the schedule identifier.
  • Constructor Details

    • Schedule

      public Schedule(Object payload, Instant deadline)
      Creates a new schedule using the current identity provider for the scheduleId and a future deadline.
      Parameters:
      payload - the message payload
      deadline - the delivery deadline
    • Schedule

      public Schedule(Object payload, String scheduleId, Instant deadline)
      Creates a new scheduled message with a given scheduleId.
      Parameters:
      payload - the payload
      scheduleId - the unique schedule identifier
      deadline - the delivery deadline
    • Schedule

      public Schedule(Object payload, Metadata metadata, String scheduleId, Instant deadline)
      Full constructor specifying payload, metadata, scheduleId, and deadline.
    • Schedule

      @ConstructorProperties({"payload","metadata","messageId","timestamp","scheduleId","deadline"}) public Schedule(Object payload, Metadata metadata, String messageId, Instant timestamp, String scheduleId, Instant deadline)
      Full constructor including message ID and timestamp.
  • Method Details

    • withPayload

      public Schedule withPayload(Object payload)
      Returns a new instance with the given payload.
      Overrides:
      withPayload in class Message
    • withMetadata

      public Schedule withMetadata(Metadata metadata)
      Returns a new instance with the given metadata.
    • withMessageId

      public Schedule withMessageId(String messageId)
      Returns a new instance with the given message ID.
    • withTimestamp

      public Schedule withTimestamp(Instant timestamp)
      Returns a new instance with the given timestamp.
    • addMetadata

      public Schedule addMetadata(Metadata metadata)
      Returns a new schedule with additional metadata.
      Overrides:
      addMetadata in class Message
    • addMetadata

      public Schedule addMetadata(String key, Object value)
      Returns a new schedule with a single metadata entry added.
      Overrides:
      addMetadata in class Message
    • addMetadata

      public Schedule addMetadata(Object... keyValues)
      Returns a new schedule with multiple metadata entries added.
      Overrides:
      addMetadata in class Message
    • addMetadata

      public Schedule addMetadata(Map<String,?> values)
      Returns a new schedule with all values from the given metadata map added.
      Overrides:
      addMetadata in class Message
    • addUser

      public Schedule addUser(User user)
      Returns a new schedule with a User added to the metadata using the configured UserProvider.
      Overrides:
      addUser in class Message
    • reschedule

      public Schedule reschedule(Duration duration)
      Returns a new Schedule with the same scheduleId and a new deadline offset by the given duration.
      Parameters:
      duration - duration to shift the schedule forward
      Returns:
      rescheduled instance
    • getScheduleId

      @NonNull public @NonNull String getScheduleId()
      Unique identifier for this scheduled message. Used to replace, cancel, or retrieve the schedule.
    • getDeadline

      @NonNull public @NonNull Instant getDeadline()
      The time at which this scheduled message should be delivered.