Class InMemoryScheduleStore
java.lang.Object
io.fluxzero.sdk.tracking.client.InMemoryMessageStore
io.fluxzero.sdk.scheduling.client.InMemoryScheduleStore
- All Implemented Interfaces:
SchedulingClient, AutoCloseable
An in-memory implementation of a scheduling store that allows the scheduling, retrieval, and management of scheduled
messages. It extends `InMemoryMessageStore` to reuse the functionalities for storing and managing messages and
implements `SchedulingClient` to support scheduling-specific operations.
This implementation provides thread-safe mechanisms for scheduling, retrieving, and cancelling messages. Messages are scheduled to be processed at specific timestamps, with support for expiration and filtering of schedules.
-
Constructor Summary
ConstructorsConstructorDescriptionInMemoryScheduleStore(Duration messageExpiration) InMemoryScheduleStore(Duration messageExpiration, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionappend(io.fluxzero.common.api.SerializedMessage... messages) asList(Map<Long, String> scheduleIdsByIndex, Serializer serializer) cancelSchedule(String scheduleId, io.fluxzero.common.Guarantee guarantee) Cancel a scheduled message using the provided delivery guarantee.protected voidvoidclose()Closes this client and releases any underlying resources or tracking registrations.default List<io.fluxzero.common.api.SerializedMessage> List<io.fluxzero.common.api.SerializedMessage> Returns a batch of schedules that are due for delivery.List<io.fluxzero.common.api.SerializedMessage> Returns a batch of schedules from the active schedule index.getFutureSchedules(Serializer serializer) default io.fluxzero.common.tracking.MessageStoreio.fluxzero.common.api.scheduling.SerializedSchedulegetSchedule(String scheduleId) Retrieves the serialized schedule associated with the given ID.protected voidpurgeExpiredMessages(Duration messageExpiration) removeExpiredSchedules(Serializer serializer) schedule(io.fluxzero.common.Guarantee guarantee, io.fluxzero.common.api.scheduling.SerializedSchedule... schedules) Schedule one or more serialized schedules with a specifiedGuarantee.voidvoidsetRetentionTime(Duration arg0) toString()voidtruncate()default <T extends io.fluxzero.common.tracking.MessageStore>
TMethods inherited from class InMemoryMessageStore
filterMessages, getMessage, notifyMonitors, notifyMonitors, registerMonitorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface SchedulingClient
cancelSchedule, hasSchedule, schedule
-
Constructor Details
-
InMemoryScheduleStore
public InMemoryScheduleStore() -
InMemoryScheduleStore
-
InMemoryScheduleStore
-
-
Method Details
-
append
-
schedule
public CompletableFuture<Void> schedule(io.fluxzero.common.Guarantee guarantee, io.fluxzero.common.api.scheduling.SerializedSchedule... schedules) Description copied from interface:SchedulingClientSchedule one or more serialized schedules with a specifiedGuarantee.- Specified by:
schedulein interfaceSchedulingClient- Parameters:
guarantee- Delivery guarantee to apply (e.g., none, sent, stored).schedules- One or more schedules to register.- Returns:
- A future that completes when the scheduling is acknowledged.
-
cancelSchedule
public CompletableFuture<Void> cancelSchedule(String scheduleId, io.fluxzero.common.Guarantee guarantee) Description copied from interface:SchedulingClientCancel a scheduled message using the provided delivery guarantee.- Specified by:
cancelSchedulein interfaceSchedulingClient- Parameters:
scheduleId- The identifier of the schedule to cancel.guarantee- Delivery guarantee for the cancellation request.- Returns:
- A future that completes when the cancellation is processed.
-
getSchedule
Description copied from interface:SchedulingClientRetrieves the serialized schedule associated with the given ID.- Specified by:
getSchedulein interfaceSchedulingClient- Parameters:
scheduleId- The ID of the schedule to retrieve.- Returns:
- The matching
SerializedSchedule, ornullif none is found.
-
append
- Overrides:
appendin classInMemoryMessageStore
-
getBatch
public List<io.fluxzero.common.api.SerializedMessage> getBatch(Long minIndex, int maxSize, boolean inclusive) Returns a batch of schedules that are due for delivery.Unlike a regular message store, this schedule store only exposes entries whose deadline has passed and whose schedule id is still active.
- Overrides:
getBatchin classInMemoryMessageStore
-
getBatch
public List<io.fluxzero.common.api.SerializedMessage> getBatch(Long minIndex, int maxSize, boolean inclusive, boolean includeFuture) Returns a batch of schedules from the active schedule index.When
includeFutureisfalse, only schedules whose deadline has passed are returned. When it istrue, future schedules are also included. This is used by the test server to discover the next hidden deadline and wake waiting trackers as soon as that deadline expires. -
setClock
-
clockChanged
protected void clockChanged() -
truncate
public void truncate()- Overrides:
truncatein classInMemoryMessageStore
-
getFutureSchedules
-
removeExpiredSchedules
-
asList
-
purgeExpiredMessages
- Overrides:
purgeExpiredMessagesin classInMemoryMessageStore
-
toString
- Overrides:
toStringin classInMemoryMessageStore
-
close
public void close()Description copied from interface:SchedulingClientCloses this client and releases any underlying resources or tracking registrations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSchedulingClient- Overrides:
closein classInMemoryMessageStore
-
getBatch
-
setRetentionTime
-
unwrap
-
getMessageStore
default io.fluxzero.common.tracking.MessageStore getMessageStore()
-