Skip to content
Demos and sample for my "Welcome to the (state) machine" talk
C# HTML CSS TSQL PowerShell Batchfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts
src
targets
.editorconfig
.gitattributes
.gitignore
LICENSE
README.md
appveyor.yml
build.cmd

README.md

Welcome to the (state) machine - Demos

A tickets booking system - based on SOA principles.

This demo aims to demonstrate how to use sagas to overcome the architectural limitations of Process Managers in distributed systems. This is the support demo of my Welcome to the (state) machine talk.

The demo assumes some knowledge of what service boundaries are and what's the role ViewModel Composition in SOA based systems. I recommend you watch the following 2 talks, by @adamralph and @mauroservienti (myself), to find out more about how to figure out your service boundaries, and how to deal with UI/ViewModel aspects in a microservices/SOA system without reintroducing coupling by doing request/response between the services.

An exhaustive dissertation about ViewModel Composition is available on my blog in the ViewModel Composition series.

How to get the sample working locally

Get a copy of this repository

Clone or download this repo locally on your machine. If you're downloading a zip copy of the repo please be sure the zip file is unblocked before decompressing it. In order to unblock the zip file:

  • Right-click on the downloaded copy
  • Choose Property
  • On the Property page tick the unblock checkbox
  • Press OK

Check your machine is correctly configured

In order to run the sample the following machine configuration is required:

  • PowerShell execution policy to allow script execution, from an elevated PowerShell run the following:
Set-ExecutionPolicy Unrestricted

NOTE: On a clean machine do not install latest version, as of this writing 13.1, of Microsoft ODBC Driver and Microsoft ODBC Command Line Utilities as the latter is affected by a bug that prevents the LocalDb instance to be accessible at configuration time.

Databases setup

To simplify LocalDB instance setup 2 PowerShell scripts, in the scripts folder, are provided for your convenience. Both need to be run from an elevated PowerShell console.

  • Run Setup-LocalDB-Instance.ps1, with elevation, to create the LocalDB instance and all the required databases
  • Run Teardown-LocalDB-Instance.ps1, with elevation, to drop all the databases and delete the LocalDB instance

The created LocalDB instance is named (localdb)\welcome-to-the-state-machine. To only recreate databases run the Recreate-Databases.ps1, with elevation, against an already created LocalDB instance.

NOTE: If you receive errors regarding "Microsoft ODBC Driver", you can work around these by connecting to the (localdb)\welcome-to-the-state-machine database using, for example, Visual Studio or SQL Managerment Studio, and running the SQL contained in the .sql file (Setup-Databases.sql or Teardown-Databases.sql) corresponding to the .ps1 file which raised the error.

NOTE: In case the database setup script fails with a "sqllocaldb command not found" error it is possible to install LocalDb as a standalone package by downloading it separately at https://www.microsoft.com/en-us/download/details.aspx?id=29062

Startup projects

Solutions is configured to use the SwitchStartupProject Visual Studio Extension to manage startup projects. The extension is not a requirement, it's handy.

Ensure the following projects are set as startup projects:

  • `website": {},
  • Reservations.Service
  • Finance.Service
  • Finance.PaymentGateway
  • Shipping.Service

NServiceBus configuration

This sample has no NServiceBus related pre-requisites as it's configured to use Learning Transport and Learning Persistence, both explicitly designed for short term learning and experimentation purposes.

They should also not be used for longer-term development, i.e. the same transport and persistence used in production should be used in development and debug scenarios. Select a production transport and persistence before developing features.

NOTE: Do not use the learning transport or learning persistence to perform any kind of performance analysis.

Disclaimer

This demo is built using NServiceBus Sagas, I work for Particular Software, the makers of NServiceBus.

You can’t perform that action at this time.