Class JpaDatabaseTaskStore
- All Implemented Interfaces:
TaskStateProvider, TaskStore
-
Constructor Summary
ConstructorsConstructorDescriptionJpaDatabaseTaskStore(jakarta.enterprise.inject.Instance<TaskAuthorizationProvider> authorizationProviderInstance) -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes a task by its ID.Retrieves a task by its ID.booleanisTaskActive(String taskId) Determines if a task is considered active for queue management purposes.booleanisTaskFinalized(String taskId) Determines if a task is in a final state, ignoring the grace period.list(ListTasksParams params, @Nullable ServerCallContext context) List tasks with optional filtering and pagination.voidSaves or updates a task.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TaskStore
isReadAuthorized
-
Constructor Details
-
JpaDatabaseTaskStore
public JpaDatabaseTaskStore() -
JpaDatabaseTaskStore
@Inject public JpaDatabaseTaskStore(@Any jakarta.enterprise.inject.Instance<TaskAuthorizationProvider> authorizationProviderInstance)
-
-
Method Details
-
save
Description copied from interface:TaskStoreSaves or updates a task. -
get
-
delete
-
isTaskActive
Determines if a task is considered active for queue management purposes.A task is active if:
- Its state is not final, OR
- Its state is final but it was finalized within the grace period
The grace period handles the race condition where events are published to Kafka while a task is active, but consumed on a replica node after the task is finalized.
- Specified by:
isTaskActivein interfaceTaskStateProvider- Parameters:
taskId- the task ID to check- Returns:
- true if the task is active (or recently finalized within grace period), false otherwise
-
isTaskFinalized
Determines if a task is in a final state, ignoring the grace period.This method performs an immediate check: returns true only if the task is in a final state (COMPLETED, CANCELED, FAILED, etc.), regardless of when it was finalized.
This method is used by the MainQueue.onClose callback to decide whether to publish the QueueClosedEvent "poison pill". By ignoring the grace period, it ensures that subscribers are terminated immediately when the task is done, providing responsive UX.
- Specified by:
isTaskFinalizedin interfaceTaskStateProvider- Parameters:
taskId- the task ID to check- Returns:
- true if the task is in a final state (ignoring grace period), false otherwise
-
list
Description copied from interface:TaskStoreList tasks with optional filtering and pagination.Authorization filtering: When a
TaskAuthorizationProviderbean is present, implementations must callcheckReadfor each candidate task and exclude tasks for which the check returnsfalse. The filtering should be applied before pagination so that page sizes are correct from the caller's perspective. If no provider is present, all tasks are returned.⚠ Custom implementation warning: Returning unfiltered results bypasses the authorization model and can leak tasks belonging to other users. Custom implementations must apply per-task
checkReadfiltering before pagination. TheTaskAuthorizationProvidershould be declared as a CDI dependency and injected via the constructor or@Inject.
-