Package org.a2aproject.sdk.server.tasks
Class BasePushNotificationSender
java.lang.Object
org.a2aproject.sdk.server.tasks.BasePushNotificationSender
- All Implemented Interfaces:
PushNotificationSender
@ApplicationScoped
public class BasePushNotificationSender
extends Object
implements PushNotificationSender
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-args constructor for CDI proxy creation.BasePushNotificationSender(PushNotificationConfigStore configStore) BasePushNotificationSender(PushNotificationConfigStore configStore, jakarta.enterprise.inject.Instance<PushNotificationPayloadFormatter> formatters) BasePushNotificationSender(PushNotificationConfigStore configStore, A2AHttpClient httpClient) BasePushNotificationSender(PushNotificationConfigStore configStore, A2AHttpClient httpClient, List<PushNotificationPayloadFormatter> formatters) -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable StringextractTaskId(StreamingEventKind event) Extracts the task ID from a StreamingEventKind event.voidsendNotification(StreamingEventKind event, @Nullable Task taskSnapshot) Sends a push notification containing a streaming event.
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
-
Constructor Details
-
BasePushNotificationSender
protected BasePushNotificationSender()No-args constructor for CDI proxy creation. CDI requires a non-private constructor to create proxies for @ApplicationScoped beans. All fields are initialized by the @Inject constructor during actual bean creation. -
BasePushNotificationSender
-
BasePushNotificationSender
@Inject public BasePushNotificationSender(PushNotificationConfigStore configStore, jakarta.enterprise.inject.Instance<PushNotificationPayloadFormatter> formatters) -
BasePushNotificationSender
public BasePushNotificationSender(PushNotificationConfigStore configStore, A2AHttpClient httpClient) -
BasePushNotificationSender
public BasePushNotificationSender(PushNotificationConfigStore configStore, A2AHttpClient httpClient, List<PushNotificationPayloadFormatter> formatters)
-
-
Method Details
-
sendNotification
Description copied from interface:PushNotificationSenderSends a push notification containing a streaming event.Called after the event has been persisted to
TaskStore. The payload format depends on the protocol version used to register the push notification configuration.- v1.0 (default): The event is wrapped in a StreamResponse format (per A2A spec section 4.3.3) with the appropriate oneof field set (task, message, statusUpdate, or artifactUpdate).
- v0.3: The payload is a v0.3
TaskJSON object, using the providedtaskSnapshot.Messageevents are skipped.
Retrieve push notification URLs or messaging configurations from
Supported event types:PushNotificationConfigStoreusing the task ID extracted from the event.Error Handling: Log errors but don't throw exceptions. Notifications are best-effort and should not fail the primary request.
- Specified by:
sendNotificationin interfacePushNotificationSender- Parameters:
event- the streaming event to send.taskSnapshot- the current state of the task after the event has been applied. Used by formatters for older protocol versions that require the full task state in notifications.
-
extractTaskId
Extracts the task ID from a StreamingEventKind event.- Parameters:
event- the streaming event- Returns:
- the task ID, or null if not available
-