Class Schedule

java.lang.Object
io.fluxzero.sdk.common.Message
io.fluxzero.sdk.scheduling.Schedule
All Implemented Interfaces:
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

  • 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, io.fluxzero.common.api.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, io.fluxzero.common.api.Metadata metadata, String messageId, Instant timestamp, String scheduleId, Instant deadline)
      Full constructor including message ID and timestamp.
  • Method Details

    • withParents

      public Schedule withParents(Object... parentIds)
      Returns a schedule owned by the current committed lifetime of each supplied Model parent. Deletion of any parent asynchronously cancels it, including cascades. Parents must already exist in the schedule's namespace. Typed IDs use their Model's identity mapping; strings are canonical IDs. Nulls are ignored. An empty argument list explicitly disables payload @Parent declarations. This explicit selection replaces (does not supplement) ownership inferred from the payload. Already delivered messages cannot be recalled, so execution guards remain necessary.
      Parameters:
      parentIds - owning Model identities
      Returns:
      a copy with explicit ownership metadata
    • withPayload

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

      public Schedule withMetadata(io.fluxzero.common.api.Metadata metadata)
      Returns a new instance with the given metadata.
      Overrides:
      withMetadata in class Message
    • withMessageId

      public Schedule withMessageId(String messageId)
      Returns a new instance with the given message ID.
      Overrides:
      withMessageId in class Message
    • withTimestamp

      public Schedule withTimestamp(Instant timestamp)
      Returns a new instance with the given timestamp.
      Overrides:
      withTimestamp in class Message
    • addMetadata

      public Schedule addMetadata(io.fluxzero.common.api.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.
    • getMetadata

      io.fluxzero.common.api.Metadata getMetadata()
    • chunked

      default boolean chunked()
    • lastChunk

      default boolean lastChunk()
    • firstChunk

      default boolean firstChunk()