-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
79 changed files
with
2,716 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Does and Don'ts | ||
Whenever creating an application that uses CQRS+ES there are several things | ||
you need to keep in mind to make it easier and minimize the potential bugs. | ||
This guide will give you some details on typical problems and how EventFlow | ||
can help you minimize the risk. | ||
|
||
## Events | ||
|
||
#### Produce clean JSON | ||
Make sure that when your aggregate events are JSON serialized, they produce | ||
clean JSON as it makes it easier to work with and enable you to easier | ||
deserialize the events in the future. | ||
|
||
- No type information | ||
- No hints of value objects (see [value objects](ValueObjects.md)) | ||
|
||
Here's an example of good clean event JSON produced from a create user event. | ||
|
||
```JSON | ||
{ | ||
"Username": "root", | ||
"PasswordHash": "1234567890ABCDEF", | ||
"EMail": "[email protected]", | ||
} | ||
``` | ||
|
||
#### Keep old event types | ||
Keep in mind, that you need to keep the event types in your code for as long as | ||
these events are in the event source, which in most cases are _forever_ as | ||
storage is cheap and information, i.e., your domain events, is expensive. | ||
|
||
However, you should still clear your code, have a look at how you can | ||
[upgrade and version your events](./EventUpgrade.md) for details on how | ||
EventFlow supports you in this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# FAQ - frequently asked questions | ||
|
||
#### Why isn't there a "global sequence number" on domain events? | ||
|
||
While this is easy to support in some event stores like MSSQL, it doesn't | ||
really make sense from a domain perspective. Greg Young also has this to say | ||
on the subject: | ||
|
||
> Order is only assured per a handler within an aggregate root | ||
> boundary. There is no assurance of order between handlers or | ||
> between aggregates. Trying to provide those things leads to | ||
> the dark side. | ||
>> [Greg Young](https://groups.yahoo.com/neo/groups/domaindrivendesign/conversations/topics/18453) | ||
#### Why doesn't EventFlow have a unit of work concept? | ||
|
||
Short answer, you shouldn't need it. But Mike has a way better answer: | ||
|
||
> In the Domain, everything flows in one direction: forward. When something bad | ||
> happens, a correction is applied. The Domain doesn't care about the database | ||
> and UoW is very coupled to the db. In my opinion, it's a pattern which is | ||
> usable only with data access objects, and in probably 99% of the cases you | ||
> won't be needing it. As with the Singleton, there are better ways but | ||
> everything depends on proper domain design. | ||
>> [Mike Mogosanu](http://blog.sapiensworks.com/post/2014/06/04/Unit-Of-Work-is-the-new-Singleton.aspx/) | ||
If your case falls within the 1% case, write an decorator for the `ICommandBus` | ||
that starts a transaction, use MSSQL as event store and make sure your read | ||
models are stored in MSSQL as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# RabbitMQ | ||
|
||
Configuring EventFlow to publish events to [RabbitMQ](http://www.rabbitmq.com/) | ||
is simple, just install the NuGet package `EventFlow.RabbitMQ` and add this to | ||
your EventFlow setup. | ||
|
||
```csharp | ||
var uri = new Uri("amqp://localhost"); | ||
|
||
var resolver = EventFlowOptions.with | ||
.PublishToRabbitMq(RabbitMqConfiguration.With(uri)) | ||
... | ||
.CreateResolver(); | ||
``` | ||
|
||
Events are published to a exchange named `eventflow` with routing keys in the | ||
following format. | ||
|
||
``` | ||
eventflow.domainevent.[Aggregate name].[Event name].[Event version] | ||
``` | ||
|
||
Which will be the following for an event named `CreateUser` version `1` for the | ||
`MyUserAggregate`. | ||
|
||
``` | ||
eventflow.domainevent.my-user.create-user.1 | ||
``` | ||
|
||
Note the lowercasing and adding of `-` whenever there's a capital letter. | ||
|
||
All the above is the default behavior, if you don't like it replace e.g. the | ||
service `IRabbitMqMessageFactory` to customize what routing key or exchange to | ||
use. Have a look at how [EventFlow](https://github.com/rasmus/EventFlow) has | ||
done its implementation to get started. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.