Skip to content

Commit ac6ce93

Browse files
vanroguclaude
andcommitted
updated eventmodeling quickstart docs for 0.2.0: features sub-builder, configureCommand/Query/Automation API, fluent raiseEvent
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0393a0f commit ac6ce93

1 file changed

Lines changed: 36 additions & 14 deletions

File tree

_posts/2025-11-21-eventmodeling-quickstart.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Add the Eventmodeling BOM to your project pom.xml to manage dependency versions:
3636
```xml
3737
...
3838
<properties>
39-
<sliceworkz.eventmodeling.version>0.1.1</sliceworkz.eventmodeling.version>
39+
<sliceworkz.eventmodeling.version>0.2.0</sliceworkz.eventmodeling.version>
4040
</properties>
4141
...
4242
<dependencyManagement>
@@ -159,7 +159,6 @@ import org.sliceworkz.eventmodeling.boundedcontext.BoundedContextBuilder;
159159
import org.sliceworkz.eventmodeling.slices.FeatureSlice;
160160
import org.sliceworkz.eventmodeling.slices.FeatureSlice.Type;
161161
import org.sliceworkz.eventmodeling.slices.FeatureSliceConfiguration;
162-
import com.example.banking.BankingBoundedContext;
163162
import com.example.banking.BankingDomain.BankingDomainEvent;
164163
import com.example.banking.BankingDomain.BankingInboundEvent;
165164
import com.example.banking.BankingDomain.BankingOutboundEvent;
@@ -174,17 +173,28 @@ public class OpenAccountFeatureSlice
174173
implements FeatureSliceConfiguration<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> {
175174

176175
@Override
177-
public void configure(
176+
public void configureCommand(
178177
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
179178
// Commands are automatically discovered, no explicit registration needed
180179
}
180+
181+
@Override
182+
public void configureQuery(
183+
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
184+
}
185+
186+
@Override
187+
public void configureAutomation(
188+
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
189+
}
181190
}
182191
```
183192

184193
**Key concepts:**
185194
- `@FeatureSlice` annotation marks this class for automatic discovery
186195
- `type = Type.STATE_CHANGE` indicates this feature handles commands
187196
- `context`, `chapter`, and `tags` provide organizational metadata
197+
- Each feature slice has three configuration methods for commands, queries, and automations
188198

189199
### 4.2: Create the Command Implementation
190200

@@ -222,23 +232,21 @@ public class OpenAccountCommand implements Command<BankingDomainEvent> {
222232
DomainConceptId accountId = DomainConceptId.create();
223233

224234
// Raise the AccountOpened event with appropriate tags
225-
result.raiseEvent(
235+
return result.raiseEvent(
226236
new AccountOpened(accountId, customerId, LocalDate.now()),
227237
Tags.of(
228238
DomainConceptTag.of(BankingDomain.CONCEPT_ACCOUNT, accountId),
229239
DomainConceptTag.of(BankingDomain.CONCEPT_CUSTOMER, customerId)
230240
)
231241
);
232-
233-
return result;
234242
}
235243
}
236244
```
237245

238246
**Key concepts:**
239247
- Commands implement `Command<EVENT_TYPE>`
240248
- `execute()` method receives a `CommandContext` and returns a `CommandResult`
241-
- Use `result.raiseEvent()` to append events to the event store
249+
- `raiseEvent()` returns the `CommandResult`, allowing fluent return statements
242250
- Tag events with domain concepts for efficient querying
243251

244252
## Step 5: Create a STATE_READ Feature Slice (Read Model)
@@ -269,11 +277,21 @@ public class AccountDetailsFeatureSlice
269277
implements FeatureSliceConfiguration<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> {
270278

271279
@Override
272-
public void configure(
280+
public void configureCommand(
281+
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
282+
}
283+
284+
@Override
285+
public void configureQuery(
273286
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
274287
// Register the read model
275288
builder.readmodel(AccountDetailsReadModel.class);
276289
}
290+
291+
@Override
292+
public void configureAutomation(
293+
BoundedContextBuilder<BankingDomainEvent, BankingInboundEvent, BankingOutboundEvent> builder) {
294+
}
277295
}
278296
```
279297

@@ -399,7 +417,9 @@ public class BankingApplication {
399417
.name("banking")
400418
.eventStorage(eventStorage)
401419
.instance(instance)
402-
.rootPackage(BankingApplication.class.getPackage()) // Scans for @FeatureSlice
420+
.features()
421+
.rootPackage(BankingApplication.class.getPackage()) // Scans for @FeatureSlice
422+
.done()
403423
.build(BankingBoundedContext.class);
404424

405425
// 4. Execute a command
@@ -482,10 +502,12 @@ Now that you have a working Event Modeling application, you can:
482502

483503
1. **Add more events** to `BankingDomainEvent` (e.g., `MoneyDeposited`, `MoneyWithdrawn`)
484504
2. **Implement decision models** to enforce business rules in commands
485-
3. **Create automations** to implement automated activities
486-
4. **Add translators** to handle inbound events from external systems
487-
5. **Implement dispatchers** for the outbox pattern to publish outbound events
488-
6. **Switch to PostgreSQL** for production-ready event storage
489-
7. **Add tests** using the `sliceworkz-eventmodeling-testing` module
505+
3. **Use aggregates** for traditional aggregate-style command handling with snapshot support
506+
4. **Create automations** to implement automated activities
507+
5. **Add translators** to handle inbound events from external systems
508+
6. **Implement dispatchers** for the outbox pattern to publish outbound events
509+
7. **Switch to PostgreSQL** for production-ready event storage
510+
8. **Add observability** with Micrometer metrics for monitoring commands, events, and read models
511+
9. **Add tests** using the `sliceworkz-eventmodeling-testing` module
490512

491513
For more examples, see the `sliceworkz-eventmodeling-examples` module in the repository.

0 commit comments

Comments
 (0)