Class Schedule
java.lang.Object
io.fluxcapacitor.javaclient.common.Message
io.fluxcapacitor.javaclient.scheduling.Schedule
- All Implemented Interfaces:
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.fluxcapacitor.javaclient.common.HasMessage
warnedAboutMissingProperty
Fields inherited from interface io.fluxcapacitor.common.api.HasMetadata
FINAL_CHUNK
-
Constructor Summary
ConstructorsConstructorDescriptionFull constructor specifying payload, metadata, scheduleId, and deadline.Schedule
(Object payload, 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 thescheduleId
and a future deadline. -
Method Summary
Modifier and TypeMethodDescriptionaddMetadata
(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 aUser
added to the metadata using the configuredUserProvider
.@NonNull Instant
The time at which this scheduled message should be delivered.@NonNull String
Unique identifier for this scheduled message.reschedule
(Duration duration) Returns a newSchedule
with the samescheduleId
and a new deadline offset by the given duration.withMessageId
(String messageId) Returns a new instance with the given message ID.withMetadata
(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.fluxcapacitor.javaclient.common.Message
asMessage, getPayload, serialize, toMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.common.HasMessage
computeRoutingKey, getMessageId, getPayloadAs, getPayloadClass, getRoutingKey, getRoutingKey, getTimestamp
Methods inherited from interface io.fluxcapacitor.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 thescheduleId
and 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
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
Returns a new instance with the given payload.- Overrides:
withPayload
in 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:
addMetadata
in classMessage
-
addMetadata
Returns a new schedule with a single metadata entry added.- Overrides:
addMetadata
in classMessage
-
addMetadata
Returns a new schedule with multiple metadata entries added.- Overrides:
addMetadata
in classMessage
-
addMetadata
Returns a new schedule with all values from the given metadata map added.- Overrides:
addMetadata
in classMessage
-
addUser
Returns a new schedule with aUser
added to the metadata using the configuredUserProvider
. -
reschedule
Returns a newSchedule
with the samescheduleId
and 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.
-