Errors Handler Flow

This flowchart shows the initialization and execution flow of the errors service.

Architecture Overview

graph TB %% External Input PubSub[("PubSub Errors Topic
event-pers.push.errors.{mode}.{group}")] %% Main Handler subgraph "Errors Handler" EH[Errors Handler] Pipeline[Processing Pipeline] subgraph "Pipeline Steps" ParseStep[Parse Message Step] CheckAbortStep[Check Abort Personalization Step] ChannelStep[Determine Channel Step] ValidateStep[Validate Error Results Step] ProcessStep[Process Error Failures Step] subgraph "Conditional Retry Steps" ShouldRetryStep{Should Retry?} ParseRetryStep[Parse Retry Count Step] CheckMaxRetryStep[Check Max Retry Count Step] ScheduleDelayStep[Schedule Retry With Delay Step] ProcessRetriableStep[Process Retriable Failures Step] end end end %% Channel System subgraph "Channel System" Registry[Channel Registry] PushChannel[Push Channel
with Error Processing] end %% Publishers & Services subgraph "Publishers & Services" RequestPublisher["Request Publisher
me-{mode}-{group}-personalization-requests"] DelayerPublisher["Delayer Publisher
event-pers.errors-retry
Exponential backoff retry queue"] ErrorsPublisher["Errors Publisher
event-pers.errors"] subgraph "Event Publishers" MobileEvents[Mobile Event Publisher
Main PubSub Client] DPEvents[DP Event Publisher
DP PubSub Client] end end %% External Services subgraph "External Services" PushCampaignService[(Push Campaign Service)] RetryQueue[(Retry Queue)] PermanentErrors[(Permanent Error Storage)] end %% PubSub Clients subgraph "PubSub Clients" MainClient[Main PubSub Client
GCloudProjectId] DPClient[DP PubSub Client
DPGCloudProjectId] PersClient[Personalization Client
PersGCloudProjectId] end %% Flow connections PubSub --> EH EH --> Pipeline Pipeline --> ParseStep ParseStep --> CheckAbortStep CheckAbortStep --> ChannelStep ChannelStep --> ValidateStep ValidateStep --> ProcessStep ProcessStep --> ShouldRetryStep ShouldRetryStep -->|Yes| ParseRetryStep ParseRetryStep --> CheckMaxRetryStep CheckMaxRetryStep --> ScheduleDelayStep ScheduleDelayStep --> ProcessRetriableStep %% Channel processing ChannelStep --> Registry Registry --> PushChannel %% Error processing paths ProcessStep --> PushChannel PushChannel --> PushCampaignService %% Retryable errors ProcessRetriableStep --> RequestPublisher RequestPublisher --> RetryQueue %% Delayed retry ScheduleDelayStep --> DelayerPublisher DelayerPublisher --> RetryQueue %% Permanent errors PushChannel --> MobileEvents PushChannel --> DPEvents MobileEvents --> PermanentErrors DPEvents --> PermanentErrors %% Final error handling ProcessStep --> ErrorsPublisher %% Client connections EH --> PersClient RequestPublisher --> MainClient DelayerPublisher --> MainClient ErrorsPublisher --> MainClient MobileEvents --> MainClient DPEvents --> DPClient PushChannel --> MainClient PushChannel --> PersClient %% Styling classDef handler fill:#fce4ec,stroke:#c2185b,stroke-width:2px classDef pipeline fill:#e3f2fd,stroke:#1976d2,stroke-width:2px classDef channel fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef publisher fill:#f3e5f5,stroke:#4a148c,stroke-width:2px classDef service fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px classDef topic fill:#fff3e0,stroke:#ef6c00,stroke-width:2px classDef client fill:#fafafa,stroke:#424242,stroke-width:2px class EH,Pipeline handler class ParseStep,CheckAbortStep,ChannelStep,ValidateStep,ProcessStep,ParseRetryStep,CheckMaxRetryStep,ScheduleDelayStep,ProcessRetriableStep pipeline class ShouldRetryStep pipeline class Registry,PushChannel channel class RequestPublisher,DelayerPublisher,ErrorsPublisher,MobileEvents,DPEvents publisher class PushCampaignService,RetryQueue,PermanentErrors service class PubSub topic class MainClient,DPClient,PersClient client

Processing Pipeline

sequenceDiagram participant PS as PubSub participant EH as Errors Handler participant Pipeline as Processing Pipeline participant Registry as Channel Registry participant PC as Push Channel participant ReqPub as Request Publisher participant EventPub as Event Publishers participant CampaignSvc as Campaign Service participant RetryQueue as Retry Queue PS->>EH: Personalization error message EH->>Pipeline: Execute processing pipeline %% Pipeline execution Pipeline->>Pipeline: 1. Parse Message Step
JSON decode to PersonalizationErrors Pipeline->>Pipeline: 2. Check Abort Personalization Step
Check if campaign/customer is cancelled Pipeline->>Registry: 3. Determine Channel Step
Get channel from message attributes Registry->>PC: Return push channel Pipeline->>Pipeline: 4. Validate Error Results Step
Check if error data is valid Pipeline->>PC: 5. Process Error Failures Step PC->>CampaignSvc: Fetch campaign data for context CampaignSvc->>PC: Campaign metadata PC->>EventPub: Publish failure events EventPub->>PS: Send to mobile/DP event topics alt Error is Retryable Pipeline->>Pipeline: 6. Parse Retry Count Step
Extract and validate retry count Pipeline->>Pipeline: 7. Check Max Retry Count Step
Compare against configured max alt Max Retry Reached PC->>EventPub: Report permanent failures Note over EventPub: Max retries exceeded, give up else Within Retry Limit alt Customer in Delayed Retry List Pipeline->>DelayerPub: 8. Schedule Retry With Delay Step
Calculate exponential backoff DelayerPub->>RetryQueue: Schedule delayed republish Note over RetryQueue: Message will retry after delay else Standard Retry Pipeline->>PC: 9. Process Retriable Failures Step PC->>ReqPub: Republish request for retry ReqPub->>RetryQueue: Send to retry queue Note over RetryQueue: Request will be retried immediately end end else Permanent Error Note over PC: Already published to event streams in step 5 end alt Processing Errors Pipeline->>EH: Handle pipeline errors EH->>PS: Publish to errors topic end EH->>PS: Acknowledge message

Channel-Specific Methods Usage

sequenceDiagram participant Handler as Errors Handler participant Registry as Channel Registry participant Channel as Channel Handler
(Push/EmbeddedMessaging) participant CampaignSvc as Campaign Service participant ReqPub as Request Publisher participant EventPub as Event Publishers participant DelayerPub as Delayer Publisher Note over Handler: Received personalization error Handler->>Registry: DetermineChannel(message attributes) Registry->>Channel: Return channel instance rect rgb(255, 240, 240) Note over Handler,EventPub: 1. ProcessFailures - Handle error failures Handler->>Channel: ProcessFailures(errors, campaign) Channel->>CampaignSvc: Fetch campaign context CampaignSvc-->>Channel: Campaign metadata Channel->>EventPub: Publish failure events Note over EventPub: Events sent to mobile/DP streams
for permanent failure tracking end alt Error is Retryable rect rgb(255, 250, 230) Note over Handler: Parse and validate retry count Handler->>Handler: Check retry count vs max (default: 5) end alt Max Retry Reached rect rgb(255, 230, 230) Note over Handler,EventPub: Report permanent failures Handler->>Channel: ProcessFailures (permanent) Channel->>EventPub: Report to failure tracking Note over EventPub: Max retries exceeded end else Within Retry Limit alt Customer in Delayed Retry List rect rgb(245, 245, 255) Note over Handler,DelayerPub: Schedule retry with exponential backoff Handler->>DelayerPub: Schedule delayed republish Note over DelayerPub: Message queued for delayed retry end else Standard Retry rect rgb(240, 255, 240) Note over Handler,ReqPub: Immediate retry Handler->>Channel: Prepare retry request Channel->>ReqPub: Republish to personalization service Note over ReqPub: Retry attempt initiated end end end else Permanent Error Note over Handler: Already published in ProcessFailures step end Note over Handler: Error processing complete

Key Components

Pipeline Processing Steps

  1. Parse Message Step: JSON deserialization of personalization errors from PubSub message

  2. Check Abort Personalization Step: Verify campaign/customer is not in cancellation list, abort if cancelled

  3. Determine Channel Step: Route to appropriate channel handler (push, embedded_messaging)

  4. Validate Error Results Step: Check if error data is valid and complete

  5. Process Error Failures Step: Handle errors, publish failure events to mobile/DP streams

Conditional Retry Steps (only if error is retryable):

  1. Parse Retry Count Step: Extract retry count from message attributes, log error details

  2. Check Max Retry Count Step: Compare retry count against max (default: 5), report permanent failures if exceeded

  3. Schedule Retry With Delay Step: (Only for configured customers) Calculate exponential backoff delay and schedule delayed republish

  4. Process Retriable Failures Step: Republish request to personalization service for immediate retry

External Dependencies

  • Multiple PubSub Clients: Main, DP, and Personalization project clients (all use cloud.google.com/go/pubsub/v2)

  • Request Publisher: Republishes requests for retryable errors back to queue

  • Event Publishers: Mobile and DP event publishing for permanent failures

  • Campaign Service: Fetches campaign metadata for error context

Error Processing Paths

  • Permanent Path: Errors → Process Failures → Event Publishers → Failure Recording Systems

  • Immediate Retry Path: Retryable errors (within retry limit) → Process Retriable Failures → Request Publisher → Personalization Service

  • Delayed Retry Path: Retryable errors (configured customers) → Schedule Delay → Delayer Publisher → Delayed Retry Queue → Request Publisher

  • Max Retry Path: Errors exceeding max retry count → Report Failures → Event Publishers → Permanent Failure Storage

  • Fatal Path: Invalid/malformed errors → Errors Publisher → Dead Letter Queue

Configuration

  • Input Topic: event-pers.push.errors.{mode}.{group} (receives from personalization service)

  • Subscription: event-pers.push.errors.{mode}.{group} (or custom via SubscriptionName param)

  • Request Republish Topic: me-{mode}-{group}-personalization-requests

  • Delayed Retry Topic: event-pers.errors-retry

  • Errors Topic: event-pers.errors

  • Channels: Push and embedded_messaging channels with error processing capabilities

Processing Features

  • Pipeline Architecture: Sequential step processing with comprehensive error handling

  • Channel-based Routing: Registry pattern for extensible channel support (push, embedded_messaging)

  • Conditional Retry Logic: ThenIfSteps pattern enables complex retry decision trees

  • Exponential Backoff: Configurable delayed retry with exponential backoff for specific customers

  • Retry Count Tracking: Automatic retry count increment using me_event_pers/retry_count attribute

  • Max Retry Protection: Prevents infinite retry loops by enforcing configurable max retry count (default: 5)

  • Abort Cancellation: Early exit for cancelled campaigns/customers to prevent wasted processing

  • Event Publishing: Dual mobile/DP event streams for comprehensive failure tracking

  • Smart Republishing: Immediate retry for standard errors, delayed retry with backoff for configured customers