Class A2AServerRoutes
This class defines all HTTP routes for the A2A protocol using the Vert.x Web Router API
(@Observes Router). Routes are registered programmatically to map HTTP requests to
A2A operations, delegating to RestHandler for processing.
Route Mapping
Routes support optional tenant prefixing and use regex patterns for flexible matching:
POST /{tenant}/message:send → sendMessage()
POST /{tenant}/message:stream → sendMessageStreaming()
GET /{tenant}/tasks → listTasks()
GET /{tenant}/tasks/{taskId} → getTask()
POST /{tenant}/tasks/{taskId}:cancel → cancelTask()
POST /{tenant}/tasks/{taskId}:subscribe → subscribeToTask()
GET /.well-known/agent-card.json → getAgentCard()
GET /{tenant}/extendedAgentCard → getExtendedAgentCard()
Authentication
Most endpoints require authentication via @Authenticated, except:
/.well-known/agent-card.json- Public agent discovery endpoint (@PermitAll)
Streaming Support
Streaming endpoints (message:stream, subscribe) use Server-Sent Events (SSE)
via SseResponseWriter. SSE responses are handled by:
- Converting
Flow.Publisherto MutinyMulti - Formatting events with
SseFormatter - Managing backpressure and client disconnection
Error Handling
All errors are caught and converted to HTTP responses via RestHandler.createErrorResponse(A2AError),
ensuring consistent error format and status codes across all endpoints.
Context Creation
Each request creates a ServerCallContext via createCallContext(RoutingContext, String),
extracting:
- User authentication from Quarkus Security
- HTTP headers (including
X-A2A-Version,X-A2A-Extensions) - Tenant ID from URL path
- Transport protocol metadata
Custom context creation is supported via CDI-provided CallContextFactory.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelTask(String body, io.vertx.ext.web.RoutingContext rc) Cancels a running task.voidcreateTaskPushNotificationConfiguration(String body, io.vertx.ext.web.RoutingContext rc) Creates a push notification configuration for a task.voiddeleteTaskPushNotificationConfiguration(io.vertx.ext.web.RoutingContext rc) Deletes a push notification configuration.voidgetAgentCard(io.vertx.ext.web.RoutingContext rc) Retrieves the public agent card for agent discovery.voidgetExtendedAgentCard(io.vertx.ext.web.RoutingContext rc) Retrieves the extended agent card with additional metadata.voidgetTask(io.vertx.ext.web.RoutingContext rc) Retrieves a specific task by ID.voidgetTaskPushNotificationConfiguration(io.vertx.ext.web.RoutingContext rc) Retrieves a specific push notification configuration.voidlistTaskPushNotificationConfigurations(io.vertx.ext.web.RoutingContext rc) Lists push notification configurations for a task.voidlistTasks(io.vertx.ext.web.RoutingContext rc) Lists tasks with optional filtering and pagination.voidmethodNotFoundMessage(io.vertx.ext.web.RoutingContext rc) Catch-all route for undefined endpoints.voidsendMessage(String body, io.vertx.ext.web.RoutingContext rc) Handles blocking message send requests.voidsendMessageStreaming(String body, io.vertx.ext.web.RoutingContext rc) Handles streaming message send requests with Server-Sent Events.static voidvoidsubscribeToTask(io.vertx.ext.web.RoutingContext rc) Subscribes to task updates via Server-Sent Events.
-
Constructor Details
-
A2AServerRoutes
public A2AServerRoutes()
-
-
Method Details
-
sendMessage
Handles blocking message send requests.Maps
POST /{tenant}/message:sendtoRestHandler.sendMessage(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String). The request body must be JSON containing a message with parts.URL Pattern:
/message:sendor/{tenant}/message:sendExample:
POST /message:send Content-Type: application/json { "message": { "parts": [{"text": "Hello"}] } }- Parameters:
body- the JSON request bodyrc- the Vert.x routing context
-
sendMessageStreaming
Handles streaming message send requests with Server-Sent Events.Maps
POST /{tenant}/message:streamtoRestHandler.sendStreamingMessage(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String). Returns a stream of task updates and artifacts as SSE events.URL Pattern:
/message:streamor/{tenant}/message:streamResponse Format:
text/event-streamwith JSON events:data: {"taskStatusUpdate":{"task":{"status":{"state":"WORKING"}}}} data: {"taskArtifactUpdate":{"artifacts":[...]}} data: {"taskStatusUpdate":{"task":{"status":{"state":"COMPLETED"}}}}- Parameters:
body- the JSON request bodyrc- the Vert.x routing context
-
listTasks
public void listTasks(io.vertx.ext.web.RoutingContext rc) Lists tasks with optional filtering and pagination.Maps
GET /{tenant}/taskstoRestHandler.listTasks(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.Integer, java.lang.String, java.lang.Boolean). Supports query parameters for filtering and pagination.URL Pattern:
/tasks?status=COMPLETED&pageSize=10Query Parameters:
contextId- Filter by conversation contextstatus- Filter by task state (SUBMITTED, WORKING, COMPLETED, etc.)pageSize- Maximum tasks to returnpageToken- Pagination tokenhistoryLength- Max history entries per taskstatusTimestampAfter- ISO-8601 timestamp filterincludeArtifacts- Include artifacts in response (boolean)
- Parameters:
rc- the Vert.x routing context
-
getTask
public void getTask(io.vertx.ext.web.RoutingContext rc) Retrieves a specific task by ID.Maps
GET /{tenant}/tasks/{taskId}toRestHandler.getTask(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.Integer). Optionally includes task history via query parameter.URL Pattern:
/tasks/{taskId}?historyLength=10- Parameters:
rc- the Vert.x routing context (taskId extracted from path)
-
cancelTask
Cancels a running task.Maps
POST /{tenant}/tasks/{taskId}:canceltoRestHandler.cancelTask(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.String). Signals the agent executor to stop processing and transition to CANCELED state.URL Pattern:
/tasks/{taskId}:cancel- Parameters:
rc- the Vert.x routing context (taskId extracted from path)
-
subscribeToTask
public void subscribeToTask(io.vertx.ext.web.RoutingContext rc) Subscribes to task updates via Server-Sent Events.Maps
POST /{tenant}/tasks/{taskId}:subscribetoRestHandler.subscribeToTask(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String). Returns a stream of task events allowing clients to reconnect to ongoing tasks.URL Pattern:
/tasks/{taskId}:subscribeUse Cases:
- Reconnecting after network interruption
- Monitoring long-running tasks
- Multiple clients observing same task
- Parameters:
rc- the Vert.x routing context (taskId extracted from path)
-
createTaskPushNotificationConfiguration
public void createTaskPushNotificationConfiguration(String body, io.vertx.ext.web.RoutingContext rc) Creates a push notification configuration for a task.Maps
POST /{tenant}/tasks/{taskId}/pushNotificationConfigstoRestHandler.createTaskPushNotificationConfiguration(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.String).URL Pattern:
/tasks/{taskId}/pushNotificationConfigsRequest Body: JSON containing webhook URL and event filters
- Parameters:
body- the JSON request body with notification configurationrc- the Vert.x routing context (taskId extracted from path)
-
getTaskPushNotificationConfiguration
public void getTaskPushNotificationConfiguration(io.vertx.ext.web.RoutingContext rc) Retrieves a specific push notification configuration.Maps
GET /{tenant}/tasks/{taskId}/pushNotificationConfigs/{configId}toRestHandler.getTaskPushNotificationConfiguration(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.String).URL Pattern:
/tasks/{taskId}/pushNotificationConfigs/{configId}- Parameters:
rc- the Vert.x routing context (taskId and configId extracted from path)
-
listTaskPushNotificationConfigurations
public void listTaskPushNotificationConfigurations(io.vertx.ext.web.RoutingContext rc) Lists push notification configurations for a task.Maps
GET /{tenant}/tasks/{taskId}/pushNotificationConfigstoRestHandler.listTaskPushNotificationConfigurations(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, int, java.lang.String). Supports pagination via query parameters.URL Pattern:
/tasks/{taskId}/pushNotificationConfigs?pageSize=10Query Parameters:
pageSize- Maximum configurations to returnpageToken- Pagination token for next page
- Parameters:
rc- the Vert.x routing context (taskId extracted from path)
-
deleteTaskPushNotificationConfiguration
public void deleteTaskPushNotificationConfiguration(io.vertx.ext.web.RoutingContext rc) Deletes a push notification configuration.Maps
DELETE /{tenant}/tasks/{taskId}/pushNotificationConfigs/{configId}toRestHandler.deleteTaskPushNotificationConfiguration(org.a2aproject.sdk.server.ServerCallContext, java.lang.String, java.lang.String, java.lang.String).URL Pattern:
/tasks/{taskId}/pushNotificationConfigs/{configId}Response: HTTP 204 No Content on success
- Parameters:
rc- the Vert.x routing context (taskId and configId extracted from path)
-
getAgentCard
@PermitAll public void getAgentCard(io.vertx.ext.web.RoutingContext rc) Retrieves the public agent card for agent discovery.Maps
GET /.well-known/agent-card.jsontoRestHandler.getAgentCard(). This is the primary discovery endpoint that clients use to understand agent capabilities, supported skills, and communication methods.URL Pattern:
/.well-known/agent-card.json(well-known URI)Authentication:
@PermitAll- Public endpoint requiring no authenticationResponse: JSON containing
AgentCardwith:- Agent name, description, version
- Capabilities (streaming, push notifications)
- Supported skills
- Communication interfaces and protocols
- Parameters:
rc- the Vert.x routing context
-
getExtendedAgentCard
public void getExtendedAgentCard(io.vertx.ext.web.RoutingContext rc) Retrieves the extended agent card with additional metadata.Maps
GET /{tenant}/extendedAgentCardtoRestHandler.getExtendedAgentCard(org.a2aproject.sdk.server.ServerCallContext, java.lang.String). Provides tenant-specific or private capabilities beyond the public agent card.URL Pattern:
/extendedAgentCardor/{tenant}/extendedAgentCardAuthentication: Required (inherits
@Authenticatedfrom class)- Parameters:
rc- the Vert.x routing context
-
methodNotFoundMessage
public void methodNotFoundMessage(io.vertx.ext.web.RoutingContext rc) Catch-all route for undefined endpoints.Handles all HTTP methods on unmatched paths with order=100 (lowest priority). Returns a
MethodNotFoundErrorwith HTTP 404 status.Purpose: Provides consistent error responses for invalid API calls instead of generic 404 HTML pages.
- Parameters:
rc- the Vert.x routing context
-
setStreamingMultiSseSupportSubscribedRunnable
-