jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
10.91k stars 1.16k forks source link

Generic notification handler not called when non generic handler also exist #969

Closed dominique-ruest closed 6 months ago

dominique-ruest commented 9 months ago

Consider the two following notificaiton handlers:

public class DocumentSignedNotificationSender : INotificationHandler<DocumentSigned>

public class PersistDomainEventsHandler<TNotification> : INotificationHandler<TNotification> where TNotification : DomainEvent

When publishing a DocumentSigned event, only the first handler is called but not the generic one. When publishing a second event, let's say 'DocumentUploaded' which has no specific handler, the generic handler does get called.

Services are registered with Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Program>())

If I add the following registration code, the generic handler gets called once in the first scenario and twice in the other. .Services.AddTransient(typeof(INotificationHandler<>), typeof(PersistDomainEventsHandler<>))

Is this a bug? Am I missing something configuration wise? Thx!

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 14 days with no activity.