question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG?] Do domain event handlers have to explicitly call SaveEntitiesAsync?

See original GitHub issue

Hello, first of all thanks again for this great reference project. I’m focusing on the Ordering bounded context, Im’ wondering if domain event handlers have to explicitly call UnitOfWork.SaveEntitiesAsync().

I understand that the Command Handler is responsible for persisting changes on one aggregate, and side effects on another aggregate have to be managed by a domain event triggering a domain event handler. The question is: does the domain event handler have to call SaveEntitiesAsync, when it is already called by the command handler?

For example, ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler explicitly calls _buyerRepository.UnitOfWork.SaveEntitiesAsync(), while UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler does not call _orderRepository.UnitOfWork.SaveEntitiesAsync(). Thanks for your time.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mvelosopcommented, May 26, 2021

Well, after a couple of years, I’d now say that the developer shouldn’t have to worry about this, because it’s a leaking detail. 😉

0reactions
luisguerrerolabcommented, May 26, 2021

Ah! My immense inexperience in real-world projects implementing Event-Driven communication makes me believe at first that everything I see, it’s magic! That’s why I wanted to re-ask this question—to make sure that it’s actually not magic and discard the probability that some middleware is doing the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Domain events: Design and implementation
The domain event dispatcher: mapping from events to event handlers. Once you're able to dispatch or publish the events, you need some kind...
Read more >
When do domain event handlers come into play?
I have a simple examle domain of two aggregate roots and one regular entity. Tenant , UserGroup and User where in this particular...
Read more >
May Domain Events handlers lead to new events?
One of the main objectives of DDD is to "make the implicit explicit". Domain Events work against this idea by introducing implicit coupling....
Read more >
Handling Domain Events with Spring
The domain event handler is a Spring bean, which means you can inject other beans into it. Once an event is published using...
Read more >
Microservices Architecture for Containerized NET Applications
It discusses architectural design and implementation approaches using .NET and. Docker containers. To make it easier to get started, the guide focuses on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found