Created
July 23, 2018 18:48
-
-
Save maldworth/14c8850cbd5b24881fd7a97abb88a14d to your computer and use it in GitHub Desktop.
for SO https://stackoverflow.com/questions/51466729/mastransit-publish-vs-send-and-how-to-manage-message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gist because SO Rep system doesn't like me... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a bit of advice with the Email Service. We have a generic Emailer Consumer. This only accepts a Command. So we made a contract similar to:
so now, my application might publish events when things happen (notice they are past tense):
UserCreated
OrderShipped
And so I may have multiple Receive Endpoints, which will subscribe to those events
UserCreatedEmailConsumer
OrderShippedEmailConsumer
And each of those consumers will query the database, and get the e-mail Template, all the information related to those events, and populate the: to, from, subject, substitute into the email template from the db, then it will issue a _sendEndpoint.Send(...). This will send a command to the SendEmailConsumer which will perform the actual send using your e-mail provider (whether it is your own in house SMTP, or a 3rd party like Sendgrid, MailGun, Sparkpost, etc...).
This is also a nice structure, because you have the ability to configure within your SendEmailConsumer, First level and Second Level retries (based on transient failures=network blip, or an outage window=sendgrid id doing a 3 hour maintenance).
Additionally, keeping the SendEmail contract generic, you can switch mail provider anytime in the future by only changing the SendEmailConsumer.