Comments (2)
Thank you for question @jgozner !
Firstly, let me quote nice explanation what policy is (from https://developer.ibm.com/technologies/java/tutorials/reactive-in-practice-1/):
Reactions (also known as policies) help to model system-initiated commands in response to events happening. For instance, we may want to initiate a command when something else happens. It’s this ‘when, then‘ notation that makes reactions very handy to use in modelling workshops. By convention, reactions are represented using lavender sticky notes. We can insert them between an event or a command, which makes it easy to model policies, with multiple commands being triggered from one event, or to attach the lavender sticky directly to a command, where a policy only has a single command associated with it.
Answering your question, in my opinion: policy logic should be placed in Event Handler when it is simple. When the logic is complex, this logic should be placed in your Domain (for example in Domain Service) and Event Handler should only delegate and coordinate this process.
There is one example of this very easy logic policy in this project:
- Given Attendee is added to Meeting
- When Fee is not empty
- Then create a Meeting Payment
internal class MeetingAttendeeAddedIntegrationEventHandler : INotificationHandler<MeetingAttendeeAddedIntegrationEvent>
{
private readonly ICommandsScheduler _commandsScheduler;
internal MeetingAttendeeAddedIntegrationEventHandler(ICommandsScheduler commandsScheduler)
{
_commandsScheduler = commandsScheduler;
}
public async Task Handle(MeetingAttendeeAddedIntegrationEvent notification, CancellationToken cancellationToken)
{
if (notification.FeeValue.HasValue)
{
await _commandsScheduler.EnqueueAsync(new CreateMeetingPaymentCommand(
Guid.NewGuid(),
new PayerId(notification.AttendeeId),
new MeetingId(notification.MeetingId),
notification.FeeValue.Value,
notification.FeeCurrency));
}
}
}
from modular-monolith-with-ddd.
That makes so much sense! Thanks for taking the time to reply and explain that :)
from modular-monolith-with-ddd.
Related Issues (20)
- Issue with 2 or more DomainNotification<> with thesame DomainEvent
- How to achieve the domain event of new entity before saving when create new entity,please?
- Contracting services HOT 1
- Getting Sql Server connection issue while building using NUKE HOT 1
- How to secure API resources (e.g. user registration endpoint) HOT 2
- Update to .NET 6.0 / 7.0? HOT 9
- Infrastructure Module and DRY
- error: User context is not available while creating meetingrouppropsala
- Handling exceptions, validation exception
- Identity Changes HOT 12
- how to execute .\build MigrateDatabase "connection_string" HOT 2
- Remove Unused `using` Directives Following .NET 7/8 Update HOT 1
- CI/CD Pipeline for Docker Image Build Validation
- is john wick ukranian?
- Why does the Member Aggregate in the Meetings module need the login information? HOT 1
- ProcessInternalCommandsCommandHandler does not work if result is success
- RUN dotnet restore "DatabaseMigrator.csproj" fails HOT 2
- OAuth2 Resource Owner Password Grant Type has been deprecated
- swagger error: API.xml file not found HOT 1
- Autofac Decorator Circular dependency issue in DomainEventsDispatcher
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modular-monolith-with-ddd.