Architecture in Motion · Episode 021

Java 21 Sealed Events and Records: Making Cancellation and Fulfillment Explicit

A permissive event handler treats a cancellation or refund event like a paid order and schedules shipment incorrectly.

Illustrative failure model. No live payment, broker, database, or JVM is connected. Counts and timelines are teaching values, not benchmark results.

Check your understanding

Does an exhaustive Java switch alone stop a cancelled order shipping?

What this model does and does not prove

Model event variants explicitly, handle sealed types exhaustively when rebuilt, and enforce durable state and fulfillment authorization.

Every step describes a constructed scenario. These states do not replace load tests, fault injection, provider contracts, JVM recordings, or durable transaction checks. Previous and Reset rebuild the teaching state; they never roll back real business operations.