MessageHandler MH Sign Up

Projection Quickstart


This quickstart gives you an example implementation of a projection.


Clone the source code from Github before you get started.


The scenario for this quickstart populates PurchaseOrder objects from events in the OrderBooking stream (the events emitted by the aggregate root quickstart).

There are 2 options here:

  • The 'prerestored' option reads the objects restored at startup.
  • The 'onthefly' option projects them during the request.

What you need to get started

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.

  "azurestoragedata": "your azure storage connection string goes here"

Once configured you can start the API project or run the unittests.

Note: it is advised to run the aggregate root quickstart first, so that the event store is populated with events.

Designed with testing in mind

MessageHandler is intented to be test friendly.

This sample contains plenty of ideas on how to test a projection without requiring a dependency on an actual storage account, and thus keep the tests fast.

  • Unit tests: To test the actual logic in the projection. Unit tests should make up the bulk of all tests in the system.
  • Component tests: To test the api used to expose the projection.
  • Contract tests: To verify that the test doubles used in the unit and 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 the how to guide to learn how to implement this pattern or get started with the learning path, where you'll build a Projection yourself in lesson 4.

Sign up to our newsletter to get notified about new content and releases

You can unsubscribe at any time by clicking the link in the footer of your emails. I use Mailchimp as my marketing platform. By clicking subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.