Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with 2 or more DomainNotification<> with thesame DomainEvent #243

Open
arvylagunamayor opened this issue Apr 24, 2022 · 0 comments
Open

Comments

@arvylagunamayor
Copy link

Im trying to handle one DomainEvent with multiple DomainNotificationHandler that doing different task. One for emitting event for subscribe module, and one for sending automated email. Based on the current implementation of "DomainEventsDispatcher.cs" file (code below). The autofac only resolving one of my DomainNotification. I can do workaround like triggering ICommandScheduler, but im not sure its the best approach.

` public async Task DispatchEventsAsync()
{
var domainEvents = _domainEventsProvider.GetAllDomainEvents();

        var domainEventNotifications = new List<IDomainEventNotification<IDomainEvent>>();
        foreach (var domainEvent in domainEvents)
        {
            Type domainEvenNotificationType = typeof(IDomainEventNotification<>);
            var domainNotificationWithGenericType = domainEvenNotificationType.MakeGenericType(domainEvent.GetType());
            var domainNotification = _scope.ResolveOptional(domainNotificationWithGenericType, new List<Parameter>
            {
                new NamedParameter("domainEvent", domainEvent),
                new NamedParameter("id", domainEvent.Id)
            });

            if (domainNotification != null)
            {
                domainEventNotifications.Add(domainNotification as IDomainEventNotification<IDomainEvent>);
            }
        }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant