Package org.a2aproject.sdk.server.grpc.quarkus
package org.a2aproject.sdk.server.grpc.quarkus
Quarkus gRPC reference implementation for the A2A protocol.
This package provides a production-ready gRPC server implementation built on Quarkus gRPC and Protocol Buffers, demonstrating best practices for A2A protocol integration with CDI, authentication, and interceptor support.
Architecture
gRPC Request (Protocol Buffers)
↓
A2AExtensionsInterceptor (metadata extraction)
↓
QuarkusGrpcHandler (@GrpcService)
├─ Protobuf → Domain conversion
├─ Create ServerCallContext
├─ Route to GrpcHandler (transport layer)
└─ Domain → Protobuf conversion
↓
GrpcHandler (transport/grpc)
↓
RequestHandler (server-common)
↓
AgentExecutor (your implementation)
Core Components
QuarkusGrpcHandler- Main gRPC service implementationA2AExtensionsInterceptor- Metadata extraction interceptorQuarkusGrpcTransportMetadata- Transport protocol identification
gRPC Methods
Unary RPC (blocking):
SendMessage- Send message and wait for completionGetTask- Get task by IDListTasks- List tasks with filteringCancelTask- Cancel task executionCreateTaskPushNotificationConfig- Configure push notificationsGetTaskPushNotificationConfig- Get push notification configListTaskPushNotificationConfigs- List push notification configsDeleteTaskPushNotificationConfig- Delete push notification configGetExtendedAgentCard- Get extended agent card
Server Streaming RPC:
SendStreamingMessage- Send message with streaming responseSubscribeToTask- Subscribe to task events
CDI Integration
Required CDI Beans:
AgentCardwith@PublicAgentCardqualifierAgentExecutorimplementation
Optional CDI Beans:
AgentCardwith@ExtendedAgentCardqualifierCallContextFactoryfor custom context creation
Usage
Add Dependency:
<dependency>
<groupId>org.a2aproject.sdk</groupId>
<artifactId>a2a-java-sdk-reference-grpc</artifactId>
<version>${a2a.version}</version>
</dependency>
Provide Agent Card:
@ApplicationScoped
public class MyAgentCardProducer {
@Produces @PublicAgentCard
public AgentCard agentCard() {
return new AgentCard.Builder()
.name("My gRPC Agent")
.description("Agent description")
.url("http://localhost:9090")
.capabilities(new AgentCapabilities.Builder()
.streaming(true)
.build())
.build();
}
}
Provide Agent Executor:
@ApplicationScoped
public class MyAgentExecutorProducer {
@Produces
public AgentExecutor agentExecutor() {
return new MyAgentExecutor();
}
}
Configuration
gRPC Server:
quarkus.grpc.server.port=9090 quarkus.grpc.server.host=0.0.0.0
Authentication:
quarkus.security.users.embedded.enabled=true quarkus.security.users.embedded.plain-text=true quarkus.security.users.embedded.users.alice=password
Customization
Custom Context Creation:
Provide a CDI bean implementing CallContextFactory:
@ApplicationScoped
public class CustomCallContextFactory implements CallContextFactory {
@Override
public <V> ServerCallContext create(StreamObserver<V> responseObserver) {
// Extract custom data from gRPC context
Context grpcContext = Context.current();
Metadata metadata = GrpcContextKeys.METADATA_KEY.get(grpcContext);
String orgId = metadata.get(
Metadata.Key.of("x-organization-id", Metadata.ASCII_STRING_MARSHALLER)
);
Map<String, Object> state = new HashMap<>();
state.put("organization", orgId);
state.put("grpc_response_observer", responseObserver);
return new ServerCallContext(
extractUser(),
state,
extractExtensions(grpcContext),
extractVersion(grpcContext)
);
}
}
Python Equivalence
This implementation provides equivalent functionality to Python's grpc.aio server:
grpc.aio.ServicerContext→ContextwithA2AExtensionsInterceptorcontext.invocation_metadata()→GrpcContextKeys.METADATA_KEYcontext.method()→GrpcContextKeys.GRPC_METHOD_NAME_KEYcontext.peer()→GrpcContextKeys.PEER_INFO_KEY
-
ClassesClassDescriptiongRPC server interceptor that captures request metadata and context information, providing equivalent functionality to Python's
grpc.aio.ServicerContext.gRPC server interceptor that offloads handler execution from the Vert.x event loop to a worker thread, using a forked gRPCContext.Quarkus gRPC service implementation for the A2A protocol.Transport metadata provider for the Quarkus gRPC reference implementation.