Skip to content

Examples

The following sections demonstrate several of the numerous scenarios that can be simplified with DCB:

Note

Most of the examples don't interact with the Event Store directly, but use higher level abstractions that allow for focusing on the business logic while demonstrating the potential of DCB. See article about Projections for more details

Constraints affecting multiple entities

The most popular use case for DCB is to enforce hard constraints that affect multiple domain entities/concepts since it was covered in the "Killing the Aggregate" blog post by Sara Pellegrini . The course subscriptions example illustrates that scenario.

Enforcing global uniqueness

Enforcing globally unique values is one of the evergreen-topics of eventual consistent applications. The unique username example demonstrates how easy this is with DCB.

Consecutive sequence

Creating a monotonic sequence without gaps is a common requirement, for example in invoice numbering.

Replacing Read Models

Due to the flexibility of DCB, it can sometimes replace entire Read Models, for example to validate Opt-In tokens or to guarantee that a product can be purchased for the displayed price.

Idempotency

Double submission is a common problem. It can usually be worked around by creating IDs on the client side, but sometimes that's not an option. DCB allows to use a dedicated idempotency id in order to prevent record duplication.


Tip

We will add more examples over time, make sure to watch the Github Repository of this website to get notified about changes