Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A2aproject A2a java Cloud Storage Config

From Leeroopedia
Knowledge Sources
Domains Cloud_Native, Storage, Configuration
Last Updated 2026-10-29 00:00 GMT

Overview

Wrapper documentation for configuring the A2A SDK's externalized storage components (JPA TaskStore and Kafka QueueManager) that enable horizontal scaling of agent deployments.

Description

By default, the A2A SDK uses in-memory implementations (`InMemoryTaskStore`, `InMemoryQueueManager`) that work for single-instance deployments. For multi-pod Kubernetes deployments, these must be replaced with externalized storage:

  • JPA TaskStore (`extras/task-store-database-jpa`): A JPA-backed `TaskStore` implementation that persists task state to a relational database (PostgreSQL). This ensures all pods share the same task state — any pod can read, update, or query any task. Activated as a CDI alternative.
  • Kafka QueueManager (`extras/queue-manager-replicated`): A Kafka-backed `QueueManager` that replicates events across pods. When an agent on Pod A enqueues an event, it is published to the Kafka topic `a2a-events`. The pod that owns the subscriber's connection consumes the event and delivers it to the client. This enables cross-pod event fan-out.

Configuration is done via environment variables in the Kubernetes ConfigMap (`04-agent-configmap.yaml`) and injected via MicroProfile Config (`@ConfigProperty`). The CDI alternative mechanism ensures the externalized implementations take precedence over in-memory defaults when on the classpath.

The cloud agent also uses the Kubernetes Downward API (`POD_NAME` from `metadata.name`) to identify which pod served each request, embedding it in artifact metadata for verification.

External Reference

Usage

  • Cloud deployment: Add `extras/task-store-database-jpa` and `extras/queue-manager-replicated` to project dependencies
  • Configuration: Set database URL, credentials, and Kafka bootstrap servers via ConfigMap environment variables
  • Pod identification: Read `POD_NAME` from environment to identify which pod served a request
  • CDI activation: The externalized implementations are activated as CDI alternatives automatically when on classpath

Code Reference

Source Location

  • Repository: a2a-java
  • Files:
    • `examples/cloud-deployment/k8s/04-agent-configmap.yaml` (L1-11)
    • `examples/cloud-deployment/server/src/main/java/org/a2aproject/sdk/examples/cloud/CloudAgentCardProducer.java` (L22-61)
    • `examples/cloud-deployment/server/src/main/java/org/a2aproject/sdk/examples/cloud/CloudAgentExecutorProducer.java` (L23-130)
  • Extras modules:
    • `extras/task-store-database-jpa/` — JPA-backed TaskStore
    • `extras/queue-manager-replicated/` — Kafka-backed QueueManager

ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: a2a-agent-config
  namespace: a2a-demo
data:
  QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://postgres:5432/a2a
  QUARKUS_DATASOURCE_USERNAME: a2a
  KAFKA_BOOTSTRAP_SERVERS: a2a-kafka-bootstrap.a2a-demo:9092

Cloud Agent Executor (Pod Identification)

public class CloudAgentExecutor implements AgentExecutor {
    @Override
    public void execute(RequestContext context, AgentEmitter emitter) throws A2AError {
        String podName = System.getenv("POD_NAME");
        emitter.startWork();

        String command = context.getUserInput("\n");
        // Process command, embed pod name in artifact
        emitter.addArtifact(List.of(new TextPart(
            "Processed by pod: " + podName)));
        emitter.complete();
    }
}

Usage Examples

Maven Dependencies for Cloud Deployment

<dependencies>
    <!-- JPA-backed task store (replaces InMemoryTaskStore) -->
    <dependency>
        <groupId>org.a2aproject.sdk</groupId>
        <artifactId>task-store-database-jpa</artifactId>
    </dependency>
    <!-- Kafka-backed queue manager (replaces InMemoryQueueManager) -->
    <dependency>
        <groupId>org.a2aproject.sdk</groupId>
        <artifactId>queue-manager-replicated</artifactId>
    </dependency>
</dependencies>

Application Properties

# Database configuration (PostgreSQL)
quarkus.datasource.jdbc.url=${QUARKUS_DATASOURCE_JDBC_URL}
quarkus.datasource.username=${QUARKUS_DATASOURCE_USERNAME}

# Kafka configuration
kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS}
mp.messaging.incoming.a2a-events.topic=a2a-events

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment