Replies: 1 comment 4 replies
-
Since you're trying to talk to another app, not just internal within your app, I'd take a look at MassTransit (or possibly NServiceBus if you have stricter requirements and need a commercial solution). MT is pretty easy to get going and should do what you need. See this super quick article I wrote recently on how to get it set up in under 5 minutes: |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a .NET 8 console application. I need to integrate support for notifications in my application. Notifications in this case means using some third party service (Apprise) to publish important events that occur when users execute command line functionality.
The way I plan on implementing this so far is to have a
NotificationEmitter
class with several methods on it (e.g.NotifyError()
,NotifyStatistic()
). Each notification "type" is responsible for handling that event in its own way, which could be storing a string in a list, or incrementing a counter for metrics. Once the entire command line execution is completed, I have aNotificationService
that should gather all metrics/strings/etc from each notification sent and build a single, large notification out of that data and publish the notification itself. This could be sent as an email, a discord notification, or something else (Apprise takes care of that for me).Is Mediatr the right tool for this? My current approach is to use
IObservable
, but this requires me to essentially reimplement a lot of the patterns that Mediatr already implements. I want to give Mediatr a shot but I'm not sure if it's the way to go. If all of the event handlers are registered in DI as transient by default, it doesn't make sense to create potentially hundreds of notification handler instances within a command line program that completes execution in 10 seconds or less. I realize I could probably register the handlers as a singleton but that seems like an anti-pattern to me.I'd love to hear from others about how Mediatr is a good fit here, and if not, maybe provide some architectural advice.
Beta Was this translation helpful? Give feedback.
All reactions