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 BasePushNotificationSender

From Leeroopedia
Knowledge Sources
Domains Server, Push_Notifications, Webhooks
Last Updated 2026-10-30 00:00 GMT

Overview

Concrete push notification webhook sender that delivers task update events to registered callback URLs via HTTP POST with authentication tokens and SSRF protection.

Description

The BasePushNotificationSender class implements the PushNotificationSender SPI as a CDI @ApplicationScoped bean. It retrieves push notification configurations from PushNotificationConfigStore, validates URLs via PushNotificationUrlValidator (SSRF protection), formats payloads using version-specific PushNotificationPayloadFormatter implementations, and sends HTTP POST requests via A2AHttpClient. Notifications are dispatched asynchronously using a configurable Executor (resolution order: instrumented wrapper, `@Named("a2a.pushNotificationDispatch")`, or ForkJoinPool). The sender handles pagination for tasks with multiple notification configs and validates notification tokens.

Usage

  • Automatic push notifications: Registered as a CDI bean — automatically invoked by MainEventBusProcessor when task events are enqueued
  • SSRF protection: URLs are validated by DefaultPushNotificationUrlValidator before delivery to prevent server-side request forgery
  • Async dispatch: Notifications are sent asynchronously to avoid blocking the event processing pipeline
  • Custom executor: Applications can provide a `@Named("a2a.pushNotificationDispatch")` Executor bean for thread pool control

Code Reference

Source Location

  • Repository: a2a-java
  • File: `server-common/src/main/java/org/a2aproject/sdk/server/tasks/BasePushNotificationSender.java`
  • Lines: L41-396

Signature

@ApplicationScoped
public class BasePushNotificationSender implements PushNotificationSender {
    // CDI no-args constructor for proxy creation
    public BasePushNotificationSender();

    // CDI injection constructor
    @Inject
    public BasePushNotificationSender(A2AHttpClient httpClient,
            PushNotificationConfigStore configStore,
            Map<String, PushNotificationPayloadFormatter> formattersByVersion,
            PushNotificationUrlValidator urlValidator,
            Instance<Executor> dispatchExecutors);

    void sendPushNotifications(String taskId, StreamingEventKind event);
    void sendPushNotifications(String taskId, Event event);
    // Internal: pagination, URL validation, async dispatch, token headers
}

Import

import org.a2aproject.sdk.server.tasks.BasePushNotificationSender;

I/O Contract

Inputs

Name Type Required Description
taskId String Yes Task to send notifications for
event StreamingEventKind / Event Yes Event to deliver as notification
httpClient A2AHttpClient Yes HTTP client for webhook delivery
configStore PushNotificationConfigStore Yes Stores notification configs per task
urlValidator PushNotificationUrlValidator Yes SSRF URL validator
dispatchExecutor Executor No (default pool) Async dispatch thread pool

Outputs

Name Type Description
HTTP POST A2AHttpResponse Webhook delivery to configured URLs
Side effect None Failures are logged, not propagated

Usage Examples

CDI Automatic Registration

// BasePushNotificationSender is automatically registered as @ApplicationScoped.
// No explicit code needed — MainEventBusProcessor calls it when events are enqueued.

// To provide a custom dispatch executor:
import jakarta.enterprise.inject.Named;
import jakarta.inject.Inject;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

@Produces
@Named("a2a.pushNotificationDispatch")
public Executor pushNotificationExecutor() {
    return Executors.newFixedThreadPool(4);
}

Custom PushNotificationSender

// Implement the SPI to customize behavior
public class CustomPushNotificationSender implements PushNotificationSender {
    @Override
    public void sendPushNotifications(String taskId, StreamingEventKind event) {
        // Custom delivery logic (e.g., email, Slack, custom webhook format)
    }
}

Related Pages

Page Connections

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