This quickstart gives you an example implementation of event processing.
Clone the source code from Github before you get started.
Scenario
In this scenario the event processor will inspect the SensorValueChanged events (emitted by the event generator) and computes the average value over a time period of 10 seconds.
What you need to get started
- The .NET 6 SDK should be installed
- The sample was created using Visual Studio 2022 community edition.
- To send events an event hubs namespace is used.
- A general purpose azure storage account is used to store the offsets of the event hubs.
- The MessageHandler.Runtime.StreamProcessing 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.
{
"eventhubsnamespace": "your event hubs connection string goes here",
"azurestoragedata": "your storage connection string goes here"
}
Also ensure an event hub named receivehub
and sendhub
is created up front in the eventhubs namespace.
And a container named leases
should be present in the azure storage account.
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 an event processor without requiring a dependency on an actual broker instance, nor storage account, and thus keep the tests fast.
- Component tests: To test the interaction between the event processor and the receive infrastructure.
- 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 stream processing pipeline.