Class InMemoryTaskStore
- All Implemented Interfaces:
TaskStateProvider,TaskStore
TaskStore and TaskStateProvider.
This implementation uses a ConcurrentHashMap to store tasks in memory.
Tasks are lost on application restart. For persistent storage, use a database-backed
implementation such as the JPA TaskStore in the extras module.
This is the default TaskStore used when no other implementation is provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes a task by its ID.@Nullable TaskRetrieves a task by its ID.booleanisTaskActive(String taskId) Determines whether a task is considered active for queue management purposes.booleanisTaskFinalized(String taskId) Determines whether a task is in a final state, ignoring the grace period.list(ListTasksParams params) List tasks with optional filtering and pagination.voidSaves or updates a task.
-
Constructor Details
-
InMemoryTaskStore
public InMemoryTaskStore()
-
-
Method Details
-
save
Description copied from interface:TaskStoreSaves or updates a task. -
get
Description copied from interface:TaskStoreRetrieves a task by its ID. -
delete
Description copied from interface:TaskStoreDeletes a task by its ID. -
list
Description copied from interface:TaskStoreList tasks with optional filtering and pagination. -
isTaskActive
Description copied from interface:TaskStateProviderDetermines whether a task is considered active for queue management purposes.This method includes the grace period in its check. A task is considered active if:
- Its state is not final, OR
- Its state is final but finalized within the grace period (now < finalizedAt + gracePeriod)
This method is used to decide whether to process late-arriving events.
- Specified by:
isTaskActivein interfaceTaskStateProvider- Parameters:
taskId- the ID of the task to check- Returns:
trueif the task is active (or recently finalized within grace period),falseotherwise
-
isTaskFinalized
Description copied from interface:TaskStateProviderDetermines whether a task is in a final state, ignoring the grace period.This method performs an immediate check: returns
trueonly if the task is in a final state (COMPLETED, CANCELED, FAILED, etc.), regardless of when it was finalized.This method is used by cleanup callbacks and MainQueue closing logic to decide whether a queue can be closed and removed. By ignoring the grace period, it ensures responsive cleanup while late in-flight events are still handled by the grace period mechanism for
isTaskActive.- Specified by:
isTaskFinalizedin interfaceTaskStateProvider- Parameters:
taskId- the ID of the task to check- Returns:
trueif the task is in a final state (ignoring grace period),falseotherwise
-