Kafka Events

12 Kafka event topics published and consumed by the Reports Service.

Event-Driven Architecture

Reports Service uses the transactional outbox pattern with DynamoDB Streams for reliable Kafka publishing. All events follow CloudEvents 1.0 format with tenant_id as partition key.

Published Events (6 topics)

Events emitted by reports-svc during report lifecycle operations.

TopicTriggerKey Payload Fields
eventzr.reports.job.queued.v1Export job createdjobId, tenantId, templateId, format
eventzr.reports.job.processing.v1Job starts processingjobId, tenantId, startedAt
eventzr.reports.report.ready.v1Report generation completejobId, tenantId, downloadUrl, format, fileSizeBytes
eventzr.reports.report.failed.v1Report generation failedjobId, tenantId, errorCode, errorMessage
eventzr.reports.report.expired.v1Report output expiredjobId, tenantId, expiredAt
eventzr.reports.export.large.v1Large export started (>1M rows)jobId, tenantId, estimatedRows

Consumed Events (6 topics)

Events consumed by reports-svc from other services.

TopicActionSource
eventzr.analytics.snapshot.created.v1Cache invalidation for analytics dataanalytics-svc
eventzr.analytics.snapshot.updated.v1Cache invalidation for updated snapshotsanalytics-svc
eventzr.studio.theme.updated.v1Refresh theme cache for PDF themingstudio-svc
eventzr.event.completed.v1Auto-generate event completion reportevent-svc
eventzr.campaign.completed.v1Auto-generate campaign reportcampaign-svc
eventzr.tour.leg.completed.v1Auto-generate tour leg reporttour-svc

CloudEvents Envelope

Example: report.ready eventjson
{
  "specversion": "1.0",
  "id": "evt-550e8400-e29b-41d4-a716-446655440000",
  "source": "reports-svc",
  "type": "com.eventzr.reports.report.ready.v1",
  "datacontenttype": "application/json",
  "time": "2026-02-24T19:30:00.000Z",
  "subject": "tenant:a0000001-0000-0000-0000-000000000001",
  "data": {
    "jobId": "job-uuid",
    "tenantId": "a0000001-0000-0000-0000-000000000001",
    "templateId": "template-uuid",
    "format": "pdf",
    "fileSizeBytes": 245760,
    "downloadUrl": "https://s3.amazonaws.com/eventzr-reports-output/...",
    "generatedAt": "2026-02-24T19:30:00.000Z"
  }
}

Outbox Pattern

Reports Service uses the transactional outbox pattern for reliable event publishing:

  1. Business operation writes to PostgreSQL + DynamoDB outbox table in same transaction
  2. DynamoDB Streams triggers the outboxProcessorHandler Lambda
  3. Handler reads new INSERT records and publishes to Kafka via OutboxService.publishToKafka()
  4. Failed publishes are retried by DynamoDB Streams (up to 3 times)