java.lang.Object
io.fluxzero.sdk.common.Message
io.fluxzero.sdk.scheduling.Schedule
- All Implemented Interfaces:
io.fluxzero.common.api.HasMetadata,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
FieldsFields inherited from interface io.fluxzero.sdk.common.HasMessage
warnedAboutMissingPropertyFields inherited from interface io.fluxzero.common.api.HasMetadata
FINAL_CHUNK -
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.@NonNull InstantThe time at which this scheduled message should be delivered.@NonNull StringUnique identifier for this scheduled message.reschedule(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.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 io.fluxzero.sdk.common.Message
asMessage, getPayload, serialize, toMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxzero.sdk.common.HasMessage
computeRoutingKey, getMessageId, getPayloadAs, getPayloadClass, getRoutingKey, getRoutingKey, getTimestampMethods inherited from interface io.fluxzero.common.api.HasMetadata
chunked, getMetadata, lastChunk
-
Field Details
-
scheduleIdMetadataKey
Metadata key for the schedule identifier.
-
-
Constructor Details
-
Schedule
Creates a new schedule using the current identity provider for thescheduleIdand a future deadline.- Parameters:
payload- the message payloaddeadline- the delivery deadline
-
Schedule
Creates a new scheduled message with a givenscheduleId.- Parameters:
payload- the payloadscheduleId- the unique schedule identifierdeadline- 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
-
withPayload
Returns a new instance with the given payload.- Overrides:
withPayloadin classMessage
-
withMetadata
Returns a new instance with the given metadata. -
withMessageId
Returns a new instance with the given message ID. -
withTimestamp
Returns a new instance with the given timestamp. -
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
Returns a new schedule with aUseradded to the metadata using the configuredUserProvider. -
reschedule
Returns a newSchedulewith the samescheduleIdand a new deadline offset by the given duration.- Parameters:
duration- duration to shift the schedule forward- Returns:
- rescheduled instance
-
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.
-