Class JpaDatabaseTaskStore
java.lang.Object
org.a2aproject.sdk.extras.taskstore.database.jpa.JpaDatabaseTaskStore
- All Implemented Interfaces:
org.a2aproject.sdk.server.tasks.TaskStateProvider,org.a2aproject.sdk.server.tasks.TaskStore
@ApplicationScoped
@Alternative
@Priority(50)
public class JpaDatabaseTaskStore
extends Object
implements org.a2aproject.sdk.server.tasks.TaskStore, org.a2aproject.sdk.server.tasks.TaskStateProvider
-
Constructor Summary
ConstructorsConstructorDescriptionJpaDatabaseTaskStore(jakarta.enterprise.inject.Instance<org.a2aproject.sdk.server.auth.TaskAuthorizationProvider> authorizationProviderInstance) -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.a2aproject.sdk.spec.TaskbooleanisTaskActive(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.org.a2aproject.sdk.jsonrpc.common.wrappers.ListTasksResultlist(org.a2aproject.sdk.spec.ListTasksParams params, @Nullable org.a2aproject.sdk.server.ServerCallContext context) voidsave(org.a2aproject.sdk.spec.Task task, boolean isReplicated) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.a2aproject.sdk.server.tasks.TaskStore
isReadAuthorized
-
Constructor Details
-
JpaDatabaseTaskStore
public JpaDatabaseTaskStore() -
JpaDatabaseTaskStore
@Inject public JpaDatabaseTaskStore(@Any jakarta.enterprise.inject.Instance<org.a2aproject.sdk.server.auth.TaskAuthorizationProvider> authorizationProviderInstance)
-
-
Method Details
-
save
public void save(org.a2aproject.sdk.spec.Task task, boolean isReplicated) - Specified by:
savein interfaceorg.a2aproject.sdk.server.tasks.TaskStore
-
get
- Specified by:
getin interfaceorg.a2aproject.sdk.server.tasks.TaskStore
-
delete
- Specified by:
deletein interfaceorg.a2aproject.sdk.server.tasks.TaskStore
-
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 interfaceorg.a2aproject.sdk.server.tasks.TaskStateProvider- 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 interfaceorg.a2aproject.sdk.server.tasks.TaskStateProvider- Parameters:
taskId- the task ID to check- Returns:
- true if the task is in a final state (ignoring grace period), false otherwise
-
list
public org.a2aproject.sdk.jsonrpc.common.wrappers.ListTasksResult list(org.a2aproject.sdk.spec.ListTasksParams params, @Nullable org.a2aproject.sdk.server.ServerCallContext context) - Specified by:
listin interfaceorg.a2aproject.sdk.server.tasks.TaskStore
-