Environment:A2aproject A2a java PostgreSQL
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Database, Cloud |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
PostgreSQL database required by the JPA-backed TaskStore and PushNotificationConfigStore extras for persistent task state in the A2A cloud-deployment example.
Description
The A2A Java SDK provides a JPA-based `TaskStore` implementation (`extras/task-store-database-jpa`) and a JPA-based `PushNotificationConfigStore` (`extras/push-notification-config-store-database-jpa`). In the cloud-deployment example, PostgreSQL is deployed as a Kubernetes StatefulSet (manifest `01-postgres.yaml`) and the agent connects via JDBC using environment variables. The Quarkus application configures `quarkus.datasource.db-kind=postgresql` with a connection pool of max 16 connections. Hibernate ORM manages the schema with `database.generation=update` in production and `drop-and-create` in tests (using H2 as an in-memory test substitute).
Usage
Use this environment for the Cloud Storage Config implementation when deploying to Kubernetes. It is required when the JPA TaskStore is enabled for persistent task state across agent pod restarts. Not needed for in-memory `InMemoryTaskStore` (default for single-instance servers).
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (Linux for K8s deployment) | PostgreSQL runs in container |
| Hardware | 512MB RAM minimum | For PostgreSQL container in K8s |
| Disk | 1GB persistent volume | For task and notification config data |
Dependencies
System Packages
- PostgreSQL 15+ (or container image `postgres:15`)
Java Libraries
- `jakarta.persistence-api` (JPA 3.1)
- Quarkus Hibernate ORM extension
- Quarkus PostgreSQL JDBC driver extension
- `org.a2aproject.sdk:a2a-java-extras-task-store-database-jpa`
- `org.a2aproject.sdk:a2a-java-extras-push-notification-config-store-database-jpa`
Credentials
The following environment variables must be set (via Kubernetes ConfigMap/Secret):
- `DATABASE_URL` — JDBC connection string (default: `jdbc:postgresql://localhost:5432/a2a`)
- `DATABASE_USER` — Database username (default: `a2a`)
- `DATABASE_PASSWORD` — Database password (default: `a2a`)
Quick Install
# In Kubernetes (via the A2A deploy script — handled automatically):
# PostgreSQL is deployed from k8s/01-postgres.yaml as a StatefulSet
# For local development with Docker:
docker run -d --name postgres-a2a \
-e POSTGRES_USER=a2a \
-e POSTGRES_PASSWORD=a2a \
-e POSTGRES_DB=a2a \
-p 5432:5432 \
postgres:15
# The Quarkus application connects automatically via application.properties:
# quarkus.datasource.db-kind=postgresql
# quarkus.datasource.jdbc.url=${DATABASE_URL:jdbc:postgresql://localhost:5432/a2a}
Code Evidence
Database configuration from `examples/cloud-deployment/server/src/main/resources/application.properties:8-13`:
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=${DATABASE_URL:jdbc:postgresql://localhost:5432/a2a}
quarkus.datasource.username=${DATABASE_USER:a2a}
quarkus.datasource.password=${DATABASE_PASSWORD:a2a}
quarkus.datasource.jdbc.max-size=16
Hibernate ORM persistence unit from `application.properties:15-19`:
quarkus.hibernate-orm."a2a-java".datasource=<default>
quarkus.hibernate-orm."a2a-java".database.generation=update
quarkus.hibernate-orm."a2a-java".packages=org.a2aproject.sdk.extras.taskstore.database.jpa,org.a2aproject.sdk.extras.pushnotificationconfigstore.database.jpa
PostgreSQL verification from `examples/cloud-deployment/scripts/verify.sh:26-33`:
POSTGRES_READY=$(kubectl get pods -n a2a-demo -l app=postgres -o jsonpath='{.items[0].status.conditions[?(@.type=="Ready")].status}' 2>/dev/null)
if [ "$POSTGRES_READY" = "True" ]; then
echo -e "${GREEN}✓ PostgreSQL is ready${NC}"
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `Connection refused: localhost:5432` | PostgreSQL not running | Start PostgreSQL container or service |
| `FATAL: password authentication failed` | Wrong credentials | Check `DATABASE_USER` and `DATABASE_PASSWORD` env vars |
| `Schema validation failed` | Schema drift between Hibernate and DB | Set `database.generation=update` or reset database |
| `H2 in tests but PostgreSQL in prod` | Dialect differences | Use `drop-and-create` in tests; `update` in production |
Compatibility Notes
- H2: Used as in-memory substitute for tests (`quarkus.datasource."a2a-java".db-kind=h2`); not suitable for production.
- Other databases: Theoretically any JPA-compatible database works, but only PostgreSQL is tested and configured.
- Connection pool: Max 16 connections per pod; adjust for higher replica counts to avoid exhausting PostgreSQL's `max_connections`.