Class QuarkusGrpcHandler
- All Implemented Interfaces:
io.grpc.BindableService,A2AServiceGrpc.AsyncService
This class provides a production-ready gRPC service built on Quarkus gRPC, implementing the A2A protocol with CDI integration, authentication, and interceptor support for metadata extraction.
CDI Integration
This class is a Quarkus gRPC service (@GrpcService) that automatically:
- Injects the public
AgentCard(required) - Injects the extended
AgentCard(optional) - Injects the
RequestHandlerfor protocol operations - Injects the
CallContextFactoryfor custom context creation (optional) - Injects the
Executorfor async operations
Security
The service is protected with @Authenticated annotation, requiring
authentication for all gRPC method calls. Configure authentication in
application.properties:
quarkus.security.users.embedded.enabled=true quarkus.security.users.embedded.plain-text=true quarkus.security.users.embedded.users.alice=password
Interceptor Registration
The @RegisterInterceptor annotation automatically registers
A2AExtensionsInterceptor to capture A2A protocol headers and
metadata before service methods are invoked.
Extension Points
To customize context creation, provide a CDI bean implementing
CallContextFactory:
@ApplicationScoped
public class CustomCallContextFactory implements CallContextFactory {
@Override
public <V> ServerCallContext create(StreamObserver<V> responseObserver) {
// Custom context creation logic
}
}
-
Constructor Summary
ConstructorsConstructorDescriptionQuarkusGrpcHandler(AgentCard agentCard, jakarta.enterprise.inject.Instance<AgentCard> extendedAgentCard, RequestHandler requestHandler, jakarta.enterprise.inject.Instance<CallContextFactory> callContextFactoryInstance, Executor executor) Constructs a new QuarkusGrpcHandler with CDI-injected dependencies. -
Method Summary
Modifier and TypeMethodDescriptionprotected AgentCardReturns the public agent card defining the agent's capabilities and metadata.protected CallContextFactoryReturns the custom call context factory, or null to use default context creation.protected ExecutorReturns the executor for running async operations (streaming subscriptions, etc.).protected AgentCardReturns the extended agent card with additional capabilities, or null if not configured.protected RequestHandlerReturns the request handler instance for processing A2A protocol requests.Methods inherited from class org.a2aproject.sdk.transport.grpc.handler.GrpcHandler
cancelTask, createTaskPushNotificationConfig, deleteTaskPushNotificationConfig, getCurrentMetadata, getCurrentMethodName, getCurrentPeerInfo, getDeploymentClassLoader, getExtendedAgentCard, getTask, getTaskPushNotificationConfig, listTaskPushNotificationConfigs, listTasks, sendMessage, sendStreamingMessage, setStreamingSubscribedRunnable, subscribeToTaskMethods inherited from class org.a2aproject.sdk.grpc.A2AServiceGrpc.A2AServiceImplBase
bindService
-
Constructor Details
-
QuarkusGrpcHandler
@Inject public QuarkusGrpcHandler(AgentCard agentCard, jakarta.enterprise.inject.Instance<AgentCard> extendedAgentCard, RequestHandler requestHandler, jakarta.enterprise.inject.Instance<CallContextFactory> callContextFactoryInstance, Executor executor) Constructs a new QuarkusGrpcHandler with CDI-injected dependencies.This constructor is invoked by CDI to create the gRPC service bean, injecting all required and optional dependencies.
Required Dependencies:
agentCard- Public agent card defining capabilitiesrequestHandler- Request handler for protocol operationsexecutor- Executor for async operations
Optional Dependencies:
extendedAgentCard- Extended agent card (can be unresolvable)callContextFactoryInstance- Custom context factory (can be unsatisfied)
- Parameters:
agentCard- the public agent card (qualified with@PublicAgentCard)extendedAgentCard- the extended agent card instance (qualified with@ExtendedAgentCard)requestHandler- the request handler for protocol operationscallContextFactoryInstance- the call context factory instance (optional)executor- the executor for async operations (qualified with@Internal)
-
-
Method Details
-
getRequestHandler
Description copied from class:GrpcHandlerReturns the request handler instance for processing A2A protocol requests.- Specified by:
getRequestHandlerin classGrpcHandler- Returns:
- the request handler
-
getAgentCard
Description copied from class:GrpcHandlerReturns the public agent card defining the agent's capabilities and metadata.- Specified by:
getAgentCardin classGrpcHandler- Returns:
- the agent card
-
getExtendedAgentCard
Description copied from class:GrpcHandlerReturns the extended agent card with additional capabilities, or null if not configured.- Specified by:
getExtendedAgentCardin classGrpcHandler- Returns:
- the extended agent card, or null if not available
-
getCallContextFactory
Description copied from class:GrpcHandlerReturns the custom call context factory, or null to use default context creation.- Specified by:
getCallContextFactoryin classGrpcHandler- Returns:
- the call context factory, or null for default behavior
-
getExecutor
Description copied from class:GrpcHandlerReturns the executor for running async operations (streaming subscriptions, etc.).- Specified by:
getExecutorin classGrpcHandler- Returns:
- the executor
-