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

Environment:A2aproject A2a java Kafka

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Messaging, Cloud
Last Updated 2026-10-29 00:00 GMT

Overview

Apache Kafka cluster required by the replicated QueueManager extra for broadcasting task events across multiple A2A agent pods in the cloud-deployment example.

Description

The A2A Java SDK's `extras/queue-manager-replicated` module implements a `ReplicatedQueueManager` that uses Kafka to replicate task events across agent instances, enabling horizontal scaling with event fan-out to all subscribers regardless of which pod holds the task. In the cloud-deployment example, Kafka is deployed via the Strimzi Kafka operator (v1.0.0, bundled manifest in `strimzi-1.0.0/`). The agent uses SmallRye Reactive Messaging with MicroProfile connectors to publish/consume on the `a2a-replicated-events` topic. Each pod uses a unique Kafka consumer group (via `POD_NAME` from the Kubernetes Downward API) to receive all events in broadcast mode.

Usage

Use this environment for the Cloud Storage Config implementation when deploying with the replicated QueueManager. It is required when multiple A2A agent pods need to share event streaming state. Not needed for single-instance servers using `InMemoryQueueManager`.

System Requirements

Category Requirement Notes
OS Any (Linux for K8s deployment) Kafka runs in container
Hardware 2GB RAM minimum For Kafka broker + ZooKeeper/KRaft
Disk 5GB persistent volume For Kafka topic data and logs

Dependencies

System Packages

  • Apache Kafka 4.2.0+ (or Strimzi-managed Kafka in K8s)

Java Libraries

  • `org.a2aproject.sdk:a2a-java-extras-queue-manager-replicated`
  • SmallRye Reactive Messaging (Kafka connector)
  • `org.apache.kafka:kafka-clients` (serializer/deserializer)
  • MicroProfile Reactive Messaging API

Credentials

The following environment variable must be set (via Kubernetes ConfigMap):

  • `KAFKA_BOOTSTRAP_SERVERS` — Kafka broker address (default: `localhost:9092`)
  • `POD_NAME` — Kubernetes pod name (from Downward API, used for unique consumer group)

Quick Install

# In Kubernetes (via the A2A deploy script — handled automatically):
# Strimzi operator is applied from strimzi-1.0.0/strimzi-cluster-operator-1.0.0.yaml
# Kafka cluster is created from k8s/02-kafka.yaml
# Topic is created from k8s/03-kafka-topic.yaml

# For local development with Docker:
docker run -d --name kafka-a2a \
    -p 9092:9092 \
    apache/kafka:4.2.0

# The Quarkus application connects via application.properties:
# kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
# mp.messaging.outgoing.replicated-events-out.connector=smallrye-kafka
# mp.messaging.incoming.replicated-events-in.connector=smallrye-kafka

Code Evidence

Kafka bootstrap configuration from `examples/cloud-deployment/server/src/main/resources/application.properties:22`:

kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}

Outgoing channel (publish to Kafka) from `application.properties:25-27`:

mp.messaging.outgoing.replicated-events-out.connector=smallrye-kafka
mp.messaging.outgoing.replicated-events-out.topic=a2a-replicated-events
mp.messaging.outgoing.replicated-events-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer

Incoming channel with broadcast consumer group from `application.properties:30-36`:

mp.messaging.incoming.replicated-events-in.connector=smallrye-kafka
mp.messaging.incoming.replicated-events-in.topic=a2a-replicated-events
# Each pod needs a unique consumer group to receive ALL events (broadcast behavior)
# Using POD_NAME from Kubernetes Downward API ensures each instance gets its own group
mp.messaging.incoming.replicated-events-in.group.id=a2a-cloud-${POD_NAME:local}
mp.messaging.incoming.replicated-events-in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
mp.messaging.incoming.replicated-events-in.auto.offset.reset=earliest

Kafka verification from `examples/cloud-deployment/scripts/verify.sh:38-44`:

KAFKA_READY=$(kubectl get kafka a2a-kafka -n kafka -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' 2>/dev/null)
if [ "$KAFKA_READY" = "True" ]; then
    echo -e "${GREEN}✓ Kafka is ready${NC}"

Common Errors

Error Message Cause Solution
`Failed to connect to kafka broker` Kafka not running or wrong address Check `KAFKA_BOOTSTRAP_SERVERS` env var
`Consumer group collision` Multiple pods using same group ID Ensure `POD_NAME` env var is set from Downward API
`native image fails on rootless Podman` Kafka devservices native image issue Using JVM image: `mirror.gcr.io/apache/kafka:4.2.0`
`Strimzi operator not ready` Operator CRDs not applied Apply `strimzi-cluster-operator-1.0.0.yaml` first

Compatibility Notes

  • Kafka devservices (tests): Quarkus auto-provisions a Kafka broker for tests; uses JVM image (not native) due to rootless Podman issues.
  • KRaft mode: Apache Kafka 4.x uses KRaft (no ZooKeeper); older Kafka versions with ZooKeeper are not tested.
  • Consumer group: The `POD_NAME`-based group ID is critical for broadcast behavior; without it, only one pod per group receives events.
  • Other messaging systems: Not supported; the replicated queue manager is Kafka-specific via SmallRye Reactive Messaging.

Related Pages

Page Connections

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