What are Projections in an Event Sourced Microservice Architecture?

In this video I will show you the different types of projections in an event-based microservice architecture and how you can use them.

Projections can be created in code in your microservice or in read-models when domain events are received and processed, for example, you process a published domain event and then store the result of the analysis in Oracle, MySQL, SQL Server, etc.

Serverless Microservices Online Courses

Update 04/03/2019: I have completed the FREE course: “Why you need serverless microservices, yesterday!“. Enroll for FREE!
At the moment, I’m working on four online courses in the following order:

 

Why You Need Serverless Microservices, Yesterday, FREE Course

WhyYouNeedServerlessMicroservices_960x520

In this course I will walk you through the many benefits of creating serverless microservices instead of the traditional node / instance approach including the use of containers. There are more than enough things to worry about when you want to create a new cloud system or transform a legacy system to operate in the cloud.

From a business point of view, there are huge benefits in going serverless rather than instance based (including containers). A very large jump in business agility can be achieved through focusing on the problems and opportunities rather than the technical jungle of traditional computing solutions.

From a technical point of view, it is almost nirvana where you can eliminate many points of failures in the architecture.

 

“How To Build An Event Store”, Paid Course

eventstore_960_520_darker

Your event store is the heart of an event sourced system. The event store is the source of truth for all business events. It needs to be able capture and replay all domain events in your system reliably and with great performance.

In this course, I will walk you through building an event store that you can re-use in your own projects. In addition, I will walk you through building a read model that allows you to query domain events from the read model.

I will also go through why building your own event store has many more advantages over using a third-party event store.

We will be building the event store in AWS DynamoDB but you can apply the design to a traditional RDMS SQL storage just as well. I will go over the pros and cons in doing so.

 

“Architecting And Designing Event Based Microservices”, Paid Course

ArchitectAndDesign

Learn the details on how to design and architect event based microservices using Domain Driven Design (DDD), Event Storming, CQRS, and EventSourcing techniques. I will show you how best combine many principles, patterns, and techniques to create an architecture with as few points of failures as possible and still deliver a great solution.

What you will learn can be applied to cloud based systems but also to traditional, on-premise systems. The benefits are great in either environments.

Whether you are designing a new system in a greenfield environment or transforming a legacy system, I will show tips & tricks that you can use depending which type of project you are in.

 

“Implementing A Serverless Microservice in AWS”, Paid Course

Code_960x520

Learn the details on how to implement a serverless microservice in AWS using Domain Driven Design (DDD), CQRS, and EventSourcing techniques.

We will build a fully functioning billing system in AWS using Visual Studio and C# .NET Core. Even if you are not familiar with C# and .NET Core, you will learn a lot of practical tips on using the different AWS services including building fully automated CI/CD pipelines.

 

I’m still working on these courses but I’m planning on publishing “Why You Need Serverless Microservices, Yesterday” and “How To Build An Event Store” first.

My New YouTube Channel

I just created my new YouTube channel “Creating Great Software”. Have a look.

I will be publishing videos about creating great software including serverless computing in AWS. In addition, I will be publishing my STRONG opinions about the state of the software industry from time to time.

I’m super excited about this new channel and I’m looking forward in seeing your feedback. See you there!

Serverless System Course

In the past 27 professional years, I have been fortunate enough to gain a lot of experience and wisdom in 10 different software industries. These experiences are not just successful accomplishments but also plenty of failures and mistakes made along the way. It is ok to make mistakes as long as you learn from them, only then you will gain true wisdom in anything you do.

Over the years, I have always thought, “If I could gather a small team, I could share my knowledge and we can create great things“. Due to many circumstances, I never had the opportunity to mentor a small team and being in full control on what we would create. By full control I mean free from politics and other constraints. The sort of freedom you need to create and explore ideas without worrying about budgets, timelines, etc. When you can foster such an environment, great things get invented. Just look at the past successes in Silicon Valley.

How can I share my experiences and wisdom most efficiently and help you achieve your goals much more rapidly rather than doing it alone? I have decided it is time to create an online school where I can share all my knowledge and wisdom from the software industry. Well, how about an online course that is very deep in all aspects. An online course that would teach you the birds eye view of concepts and then drills down into the very deep aspects of it. A course that could show you actually how to put the conceptual components together in a very cohesive way. All the different pieces put together in an architecture that makes real sense and is practical and maintainable. We’ll leave the fluff out and concentrate on the entire system starting from a users perspective and walk backwards into the technical implementation details. In short, a

Serverless System Master Class

This master class would be extensive and we will go into a lot of details until we have built a working system that you could use in your future projects. As a minimum, you would learn a lot of concepts and software architecture. Since technology is always changing, I believe that the concepts will be more valuable then the implementation details in the course. In addition, how you bring these concepts together and why are extremely important because in your day-to-day work, you will have constraints that you need to work with and make compromises. There is no perfect architecture and even in this master class, you will touch on many different options one could take and why.

Please let me know if you are interested in the Serveless System Master Class. I would love to hear your feedback as I work on the course. I plan to post regular updates on my blog here.

Leave a comment below or contact me directly at thomasjaeger at gmail dot com and let me know your level of interest, please!

Software Quality

As you may know, I’m working on an open source project called Visual MASM which is an IDE to create assembly applications for Windows just as easy as the Delphi or Visual Studio IDEs provide. Well, at least that is my goal.

I was looking back on why I want to create a commercial application in the Real Estate industry using my very own assembler IDE and was reading what I wrote about using assembly in the first place: Why Assembler?

There are so many languages and tools available today in order to program a solution. I have used almost all of them in the past 32 years of programming. Why on earth use assembly for Windows? For a clear business reason, Windows “owns” the world wide market and is used in over 90% of computers as of today. Never mind Linux, MacOS, etc. I mean, Windows “owns” it. Period. It makes total sense to develop for Windows when you create a commercial solution.

The fact that Windows owns the market; however, is still secondary to my motivation to create a commercial application for Windows using the assembly language. The main reason is really: Software Quality.

Quality in general, in my opinion, means paying attention to every detail. Because one pays attention to every detail, you are forced to make many decisions. As you abstract into higher languages, these decisions have been made for you. Because of this, you are no longer able to make detailed decisions. In order to pay attention to the detail of software quality, you have passion to follow through with it. Being able to make these detailed decisions also offers freedom and control of the creation process. That’s the ultimate power of high, software quality. You must have control in order to make software quality decisions.

So, paying attention to detail with passion is equivalent to high software quality. It is that simple.

 

What is a great software design?

I know everyone has their own opinion about what a great software design really is. For me, it’s rather very simple and be summarized in one sentence:

“A great software design can easily be changed in the future.”

In all of my designs, this is my primary goal in any architecture. Be very, very, careful of any library, frameworks, etc. you are thinking about adding. Do not add accidental complexity to your system because it saved you a few lines of code. Do not do it. Keep it simple before you start adding dependencies in your code. You will own this dependency for a long time.

If you are starting a greenfield project, start simple and stay simple until you have no choice and add additional complexity. Resist the temptation of adding this “cool” library or framework.

So, remember, “A great software design can easily be changed in the future.” Stick to your software architecture and stay disciplined and avoid feature-creep in the design. Don’t cut corners and let the team members know that it is important to keep the design simple.

There is enough complexity to deal with because you are creating software. Concentrate on the Ubiquitous Language. Make sure you see that language in your code.

Well, enough rambling, just wanted to write down some thoughts and to remind myself as well.

Creating IDs with CQRS and Event Sourcing in Java and .NET

I’m currently working on a cloud-based system that uses microservices with domain driven design and CQRS and Event Sourcing in Java. I love C# and .NET but I decided to do this in Java for several reasons. This could have been done in C# just as well. In fact, this system is a mix of some C# microservices and Java microservices. The important thing is that we are using the same concepts that are applicable when doing DDD and CQRS and Event Sourcing.

Anyways, I wanted to put down my thoughts on what I have been thinking about since last week and I hope this might be useful to anyone who came across the same question. So, my question since last week was this:

“Who creates an entity id in DDD when doing CQRS and Event Sourcing?”

Well, the way I have been doing this was as follows:

  1. When an application service executes a use case via one of its methods, it can create a new entity via a new immutable value object. All my entities’ ids are immutable value objects.
  2. Sometimes, a factory in the domain model creates new entities. Again, the entities’ ids are created via immutable value objects.
  3. Sometimes, a domain service creates new entities with immutable value objects.

This is all fine and good. I started to look at Greg Young‘s sample C# project at his Github here. For this who do not know him, he is a fantastic speaker and mentor for CQRS and Event Sourcing. Check out his videos, papers, and blog posts. Excellent material. He has a free 6 hour video here. And, while you are at it, check out his video about: “7 Reasons Why DDD Projects Fail“.

What poked my interest was this particular line in his CreateInventoryItem command code:

public class CreateInventoryItem : Command {
    public readonly Guid InventoryItemId;
    public readonly string Name;

    public CreateInventoryItem(Guid inventoryItemId, string name)
    {
        InventoryItemId = inventoryItemId;
        Name = name;
    }
}

If you look closely on line 5, you will see that the entity id inventoryItemId is being passed as part of the CreateInventoryItem command. This is a small but important detail.

I had an interesting thread discussion with Greg Young about this here. Greg raised a few good questions:

  1. What about when you want to send 3 commands?
  2. How will you start returning ids from commands?
  3. What if a command creates 3 entities?
  4. How will the domain get those ids back to the client?
  5. My UI is creating an account then the next step is managing some details. How does the UI go from one step to the next without knowing the account id?

As you can see, there are several good reasons why a client would want to create the ids instead of the domain model. Another reason I would want to add to this is that if the domain would create the ids, it would violate the goal of keeping track of all state changes in domain events with the commands as the initiators. In my opinion:

In a CQRS based system with Event Sourcing, commands carry all attributes that are required to execute the command including the creation of identities.

So, a client can create a command with ids that are based on Guids/Uuids and then send these creation commands with those ids. This allows you to do things such as persisting the commands and being able to replay those commands as well with 100% accuracy because the domain model with arrive every time to a deterministic state when you replay the domain events.

I like this very much and it provides a lot of freedom with inductive UIs / task based UIs.

Microservices by Martin Fowler

In the last 6 months or so, I’ve become a huge fan of Microservices. I love the concept because Microservices are a fantastic extension of domain driven design. One of the core behaviors of Microservices is that no other process is allowed to talk to the data it contains directly (in a database, for example). Any process that needs access to this data, needs to talk to the Microservice. This is exactly what a business entity (aggregate or not) in a domain model is doing. This is what encapsulation in object orientation is all about. To be more specific, a typical domain object has behavior and data, as you know. A domain object will not (and should not) let any other object or process access its data until it passes through its behavior(s). That’s why domain objects (entities) have clearly defined interfaces to talk to.

Now, if you scale this behavior up into components that run in their own processes, these microservices are doing the same thing but from a component point of view: “No other object running in another process is allowed to access another process’s data unless it talks to the behavior of this other component, the other microservice”. This has been my observation and I really have become to like the concept of Microservices. Microservices are a fantastic way of building cloud-based software and with the right PaaS solution, you can create Microservices on premise and simply deploy to a PaaS that also runs on premise or in a public cloud such as Cloud Foundry or AWS, for example.

I’m a huge fan of Martin Fowler. It is not “official” until Martin Fowler has written or spoken about any subject in the Software Industry. Anyway, here is Martin Fowler’s awesome 25 minute explanation of Microservices.

Updated C# Reference Implementation

I have updated my C# reference implementation and included FluentValidation on some of the DTO objects. I also updated the ErrorMap to include validations on the server side as well as on the WPF client side. This version also includes a sample SQL Server Persistence Provider. As always, you can get the latest code on my GitHub repo.

Slides for Sacramento .NET User Group

Update 04-05-2015: I completed the SQL Server Provider. Latest code is on GitHub.

I had a lot of fun presenting last night at the Sacramento .NET user group. It was great to hear that people learned a lot and are looking forward in incorporating the things they have learned about the Provider Model design pattern and object persistence in general into their own projects. The slides are available for download here. The source code of the entire reference implementation is available here. I will be finishing up the SQL Server provider within the next few days and make it available in my GitHub repo.