Introduction
In this article, we will look at Inventory Manager Application which is following CQRS architecture with decoupled messaging infrastructure component that was built in the previous article. Use cases for Inventory Manager are based on “Super simple cqrs” example by Greg Young. In Inventory Manager, only the first use case of creating an inventory item has been implemented.
Note that this post is part of series of articles, links for all the articles in the series are provided below:
- Introduction
- Need for Enterprise Servicebus Frameworks and Decoupled messaging with their samples
- Inventory Manager - CQRS application (with decoupled messaging) - Commands (this article)
- Inventory Manager - CQRS application (with decoupled messaging) - Aggregate and Event Sourcing
- Inventory Manager - CQRS application (with decoupled messaging) - ReadSide
Inventory Manager
Code for this application is on GitHub Repository - Located Here.
The technology stack used is as follows:
- Azure web and worker roles
- MassTransit (version 2.9.9) with Azure service bus
- Azure Storage – Table for storing events
- The Inventory Manager also uses
IServicebus
abstraction, which was explained in the previous articles.
User Experience
- Only the First Use case for creating an inventory has been implemented
- Thus we have 2 screens, one that shows list of inventory items and the other that allows adding inventory.
- When user clicks on “Add New Inventory”, he will be redirected to the following screen where name of the inventory is asked.
- Once user clicks “Add” button, command message is fired and then he is redirected to listing screen.
- The command is then processed by the worker process, which may take time after which the user can see the updated list. Thus a "Refresh" button has been provided on the Listing screen.
- This is following the PRG pattern.
Running the Application
Web Role
Project Dependencies
Responsibilities
Worker Role
Project Dependencies
Responsibilities
We will be looking at the implementation of some of these in the next article. Worker Role also uses the IServicebus
interface for subscribing to commands, publishing and subscribing to events.
- Handling the command
- Calling behavior on the domain, Aggregate
- Persisting
EventSourced
Aggregate, i.e., events in EventStore
- Publishing Events upon save of Aggregate, ensuring that save and publish happen in atomic manner
- Providing handler for the published event and updating the Read Model in the handler
Next Article in the Series
The next article in the series will focus on Aggregate and Eventsourcing in Inventory Manager application.
For a complete list of articles in this series, please go to the Introduction section of this article.
Thanks for reading the articles, hope they are proving insightful.
References
- “Super simple cqrs” example by Greg Young
- PRG Pattern