Skip to content

Outbox framework improvements: builder, interceptors, fair queue, graceful shutdown, dialect schemas#11

Merged
leonlee merged 2 commits intomainfrom
feature/improvement-design
Feb 6, 2026
Merged

Outbox framework improvements: builder, interceptors, fair queue, graceful shutdown, dialect schemas#11
leonlee merged 2 commits intomainfrom
feature/improvement-design

Conversation

@leonlee
Copy link
Copy Markdown
Owner

@leonlee leonlee commented Feb 6, 2026

Summary

  • Builder pattern on OutboxDispatcher with required connectionProvider, eventStore, listenerRegistry
  • Single-listener registry keyed by (aggregateType, eventType) with AggregateType.GLOBAL default
  • EventInterceptor for cross-cutting before/after dispatch hooks (audit, logging, metrics)
  • Fair queue draining: 2:1 weighted round-robin (hot 2/3, cold 1/3) between hot and cold queues
  • Graceful shutdown with accepting flag, shutdown() + awaitTermination with configurable drain timeout
  • AbstractJdbcEventStore hierarchy: H2 (subquery claim), MySQL (UPDATE...ORDER BY...LIMIT), PostgreSQL (FOR UPDATE SKIP LOCKED + RETURNING)
  • JdbcEventStores ServiceLoader registry with detect(DataSource) auto-detection
  • Dialect-specific schema files (H2, MySQL, PostgreSQL) shipped in the JAR under schema/
  • Schema-diff CI workflow using sqldef to generate migration DDL on PRs
  • Refactored package structure (JDBI-inspired), renamed to EventStore/OutboxEvent/EventStatus
  • Added outbox-demo (H2, no Spring) and outbox-spring-demo (Spring Boot REST)
  • Comprehensive test coverage (~141 tests)

Test plan

  • mvn test — all 141 tests pass
  • mvn -pl outbox-jdbc package -DskipTests — schema files present in JAR
  • Verify schema-diff workflow triggers on PR with schema changes
  • Run outbox-demo and outbox-spring-demo end-to-end

🤖 Generated with Claude Code

Lee and others added 2 commits February 6, 2026 18:48
Ship canonical H2, MySQL, and PostgreSQL schema files in the outbox-jdbc
JAR under schema/. Add a GitHub Actions workflow that diffs schema
changes on PRs using sqldef. Update README with multi-dialect table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The GITHUB_TOKEN needs explicit write permission to post PR comments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

Schema Diff

H2

New file (no baseline on main).

MySQL

-- dry run --
BEGIN;
CREATE TABLE outbox_event (
  event_id VARCHAR(36) PRIMARY KEY,
  event_type VARCHAR(128) NOT NULL,
  aggregate_type VARCHAR(64),
  aggregate_id VARCHAR(128),
  tenant_id VARCHAR(64),
  payload JSON NOT NULL,
  headers JSON,
  status TINYINT NOT NULL,
  attempts INT NOT NULL DEFAULT 0,
  available_at DATETIME(6) NOT NULL,
  created_at DATETIME(6) NOT NULL,
  done_at DATETIME(6),
  last_error TEXT,
  locked_by VARCHAR(128),
  locked_at DATETIME(6)
);
CREATE INDEX idx_status_available ON outbox_event(status, available_at, created_at);
COMMIT;

PostgreSQL

-- dry run --
BEGIN;
CREATE TABLE outbox_event (
  event_id VARCHAR(36) PRIMARY KEY,
  event_type VARCHAR(128) NOT NULL,
  aggregate_type VARCHAR(64),
  aggregate_id VARCHAR(128),
  tenant_id VARCHAR(64),
  payload JSONB NOT NULL,
  headers JSONB,
  status SMALLINT NOT NULL,
  attempts INT NOT NULL DEFAULT 0,
  available_at TIMESTAMPTZ NOT NULL,
  created_at TIMESTAMPTZ NOT NULL,
  done_at TIMESTAMPTZ,
  last_error TEXT,
  locked_by VARCHAR(128),
  locked_at TIMESTAMPTZ
);
CREATE INDEX idx_status_available ON outbox_event(status, available_at, created_at);
COMMIT;

@leonlee leonlee merged commit 4f61d43 into main Feb 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant