MessageHandler MH Sign Up

Task Processing Quickstart

T

This quickstart gives you an example implementation of task processing.

CLONE

Clone the source code from Github before you get started.

Scenario

In this scenario a projection will write notifications that need to be sent in the future, when the notification preferences of the user get set as well, to a data store.

The task processor will query the data store for emails that are ready to be sent, and send them out.

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.

{
  "servicebusnamespace": "your azure service bus connection string goes here",
  "sqlserverconnectionstring": "your azure service bus connection string goes here"
}

Also ensure a queue named emails 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 task processor without requiring a dependency on an actual data store, and thus keep the tests fast.

  • Component tests: To test the coordination logic in the task processor.
  • 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.
  • Integration tests: To test the integration with the data store that is holding the tasks.

How to implement it yourself

Check out the how to guide to learn how to dispatch a command from a task processor, or get started with our learning path, where you'll implement both a manual and an automated version of the task processing pattern in respectively lesson 11 and lesson 12.

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.