Class Schedule
java.lang.Object
io.fluxzero.sdk.common.Message
io.fluxzero.sdk.scheduling.Schedule
- All Implemented Interfaces:
HasMessage
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic StringMetadata key for the schedule identifier.Fields inherited from interface HasMessage
warnedAboutMissingProperty -
Constructor Summary
ConstructorsConstructorDescriptionSchedule(Object payload, io.fluxzero.common.api.Metadata metadata, String scheduleId, Instant deadline) Full constructor specifying payload, metadata, scheduleId, and deadline.Schedule(Object payload, io.fluxzero.common.api.Metadata metadata, String messageId, Instant timestamp, String scheduleId, Instant deadline) Full constructor including message ID and timestamp.Creates a new scheduled message with a givenscheduleId.Creates a new schedule using the current identity provider for thescheduleIdand a future deadline. -
Method Summary
Modifier and TypeMethodDescriptionaddMetadata(io.fluxzero.common.api.Metadata metadata) Returns a new schedule with additional metadata.addMetadata(Object... keyValues) Returns a new schedule with multiple metadata entries added.addMetadata(String key, Object value) Returns a new schedule with a single metadata entry added.addMetadata(Map<String, ?> values) Returns a new schedule with all values from the given metadata map added.Returns a new schedule with aUseradded to the metadata using the configuredUserProvider.default booleanchunked()default booleanstatic ScheduleforDeadline(Object value, Deadline declaration, Instant referenceTime) Resolves a Model deadline declaration at a common reference time.@NonNull InstantThe time at which this scheduled message should be delivered.io.fluxzero.common.api.Metadata@NonNull StringUnique identifier for this scheduled message.booleanWhether the schedule identity was selected explicitly, rather than generated by a convenience constructor.default booleanreschedule(Duration duration) Returns a newSchedulewith the samescheduleIdand a new deadline offset by the given duration.withMessageId(String messageId) Returns a new instance with the given message ID.withMetadata(io.fluxzero.common.api.Metadata metadata) Returns a new instance with the given metadata.withParents(Object... parentIds) Returns a schedule owned by the current committed lifetime of each supplied Model parent.withPayload(Object payload) Returns a new instance with the given payload.withTimestamp(Instant timestamp) Returns a new instance with the given timestamp.Methods inherited from class Message
asMessage, getPayload, getRoutingKey, serialize, toMessageMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HasMessage
computeRoutingKey, getMessageId, getPayloadAs, getPayloadClass, getRoutingKey, getRoutingKey, getTimestamp
-
Field Details
-
scheduleIdMetadataKey
Metadata key for the schedule identifier. -
FIRST_CHUNK
- See Also:
-
FINAL_CHUNK
- See Also:
-
CHUNK_INDEX
- See Also:
-
-
Constructor Details
-
Schedule
-
Schedule
-
Schedule
-
Schedule
-
-
Method Details
-
forDeadline
Resolves a Model deadline declaration at a common reference time. Null remains null; a Schedule keeps its own time. Plain payloads (including Message envelopes) use the annotation's cron or delay. A disabled cron returns null. This factory only constructs a value and never stores or dispatches it.- Parameters:
value- the declaration resultdeclaration- annotation supplying one-shot timingreferenceTime- reference shared by before/after evaluation- Returns:
- the desired schedule, or null when inactive
-
withParents
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@Parentdeclarations. 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
-
hasExplicitScheduleId
public boolean hasExplicitScheduleId()Whether the schedule identity was selected explicitly, rather than generated by a convenience constructor. -
withPayload
Returns a new instance with the given payload.- Overrides:
withPayloadin classMessage
-
withMetadata
Returns a new instance with the given metadata.- Overrides:
withMetadatain classMessage
-
withMessageId
Returns a new instance with the given message ID.- Overrides:
withMessageIdin classMessage
-
withTimestamp
Returns a new instance with the given timestamp.- Overrides:
withTimestampin classMessage
-
addMetadata
Returns a new schedule with additional metadata.- Overrides:
addMetadatain classMessage
-
addMetadata
Returns a new schedule with a single metadata entry added.- Overrides:
addMetadatain classMessage
-
addMetadata
Returns a new schedule with multiple metadata entries added.- Overrides:
addMetadatain classMessage
-
addMetadata
Returns a new schedule with all values from the given metadata map added.- Overrides:
addMetadatain classMessage
-
addUser
-
reschedule
-
getScheduleId
Unique identifier for this scheduled message. Used to replace, cancel, or retrieve the schedule. -
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()
-