This quickstart gives you an example implementation of a reaction.
Clone the source code from Github before you get started.
Scenario
This scenario covers sending a notification email in response to a PurchaseOrderBooked
event (which is sent by the aggregate root quickstart);
What you need to get started
- The .NET 6 SDK should be installed
- The sample was created using Visual Studio 2022 community edition.
- To receive events an azure service bus namespace is used.
- The MessageHandler.Runtime.AtomicProcessing package is available from nuget.org
Running the sample
Prior to being able to run the sample, you need to configure the user secrets file.
In the secrets file you must specify the following configuration values.
{
"servicebusnamespace": "your azure service bus connection string goes here",
}
Also ensure a topic named orderbooking.events
, with a subscription named orderbooking.worker
is created up front in the service bus namespace.
Once configured you can start the worker or run the unittests.
Designed with testing in mind
MessageHandler is intented to be test friendly.
This sample contains plenty of ideas on how to test a reaction without requiring a dependency on an actual broker instance, and thus keep the tests fast.
- Component tests: To test the reaction logic and it's interaction with the email service.
- Contract tests: To verify that the test doubles used in the component tests are behaving the same as an actual dependency would. Note: contract verification files are often shared between producers and consumers of the contract.
How to implement it yourself
Check out this how to guide to learn how to configure a reaction yourself or get started with the learning path, where you'll build both a transient reaction in lesson 8 and a guaranteed reaction in lesson 9.