Class JpaDatabaseTaskStore
java.lang.Object
io.a2a.extras.taskstore.database.jpa.JpaDatabaseTaskStore
- All Implemented Interfaces:
TaskStateProvider,TaskStore
@ApplicationScoped
@Alternative
@Priority(50)
public class JpaDatabaseTaskStore
extends Object
implements TaskStore, TaskStateProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidio.a2a.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.voidsave(io.a2a.spec.Task task)
-
Constructor Details
-
JpaDatabaseTaskStore
public JpaDatabaseTaskStore()
-
-
Method Details
-
save
public void save(io.a2a.spec.Task 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
-