outbox-demo · sequence diagram

Scenario E · Permanent broker failure

Kafka keeps failing. On the third attempt the event moves to DEAD and the relay stops retrying it.

1 transaction Mainscenarios OrderServicecreateOrder() OutboxRelaypublishPendingEvents() FakeDatabasesimulated DB FakeKafkaorders.events PaymentConsumerhandle(offset) createOrder("Eve") INSERT orders + outbox (NEW) COMMIT orderId setFailuresToSimulate(100) Relay run 1 publishPendingEvents() SELECT pending 1 event (NEW) UPDATE status=PROCESSING send(key=orderId, eventId) RuntimeException: Broker unavailable UPDATE FAILED, attempts=1 attempts=1 retry on next run (1 of 3) Relay run 2 publishPendingEvents() SELECT pending 1 event (FAILED) UPDATE status=PROCESSING send(key=orderId, eventId) RuntimeException: Broker unavailable UPDATE FAILED, attempts=2 attempts=2 retry on next run (2 of 3) Relay run 3 publishPendingEvents() SELECT pending 1 event (FAILED) UPDATE status=PROCESSING send(key=orderId, eventId) RuntimeException: Broker unavailable UPDATE FAILED, attempts=3 attempts=3 attempts ≥ MAX_ATTEMPTS (3): give up UPDATE status=DEAD Relay run 4: nothing pending publishPendingEvents() SELECT pending 0 events (DEAD is not retried) nothing to publish setFailuresToSimulate(0) Result: Kafka is back, but the event is already DEAD; no payment for Eve
Solid arrows: calls. Dashed: replies. Red: errors and crashes. Dashed blue boxes: database transactions; amber: the duplicate branch.

What to look for