Giter Site home page Giter Site logo

oktaykir / eventflow.example Goto Github PK

View Code? Open in Web Editor NEW
200.0 15.0 45.0 136 KB

DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.

License: Apache License 2.0

C# 100.00%
eventflow cqrs cqrs-es-architecture ges eventstore rabbitmq sagas event-sourcing event-driven dotnet-core

eventflow.example's Introduction

EventFlow.Example

Hits GitHub issues Build Status PRs Welcome

DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.

Event Sourcing/CQRS Architecture

The most common CQRS/ES architecture would look like following diagram OverallArchitecture

The example consists of the following concepts, each shown below

  • Aggregates
  • Command bus and commands
  • Synchronous subscriber
  • Event store (GES)
  • In-memory read model.
  • Snapshots (MongoDb)
  • Sagas
  • Event publising (In-memory, RabbitMq)
  • Metadata
  • Command bus decorator, custom value object, custom execution result, ...

Configuration

var resolver = EventFlowOptions.New
    .UseAutofacContainerBuilder(new ContainerBuilder())
    .Configure(c => c.ThrowSubscriberExceptions = true)
    .AddEvents(typeof(ExampleEvent))
    .AddEvents(typeof(ResetEvent))
    .AddCommands(typeof(ExampleCommand))
    .AddCommands(typeof(ResetCommand))
    .AddCommandHandlers(typeof(ExampleCommandHandler))
    .AddCommandHandlers(typeof(ResetCommandHandler))
    .ConfigureEventStore()
    .ConfigureMongoDb(client, SNAPSHOT_CONTAINER_NAME)
    .AddSnapshots(typeof(ExampleSnaphost))
    .UseMongoDbSnapshotStore()
    .RegisterServices(sr => sr.Register(i => SnapshotEveryFewVersionsStrategy.Default))
    .RegisterServices(DecorateCommandBus)
    .PublishToRabbitMq(RabbitMqConfiguration.With(new Uri(@"amqp://test:test@localhost:5672"), true, 4, "eventflow"))
    .UseInMemoryReadStoreFor<Aggregates.ReadModels.ExampleReadModel>()
    .AddJobs(typeof(ExampleJob))
    .CreateResolver());

๐Ÿ“ฆ Stack

๐Ÿค Contributing

  1. Fork it ( https://github.com/OKTAYKIR/EventFlow.Example/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

โœจ Contributors

GitHub Contributors Image

Show your support

Please โญ๏ธ this repository if this project helped you!

๐Ÿ“ License

Apache-2.0 ยฉ Oktay Kฤฑr

eventflow.example's People

Contributors

oktaykir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eventflow.example's Issues

Upgrading some stuff

@suadev, I get the following error after running the application:

12:17:48:558 [Debug]: Execution of command 'ExampleCommand' with ID 'command-a478d189-d908-4bb9-918f-c7507b1eb9ee' on aggregate 'EventFlowExample.Aggregates.ExampleAggregate' failed due to exception 'TypeInitializationException' with message: The type initializer for 'MongoDB.Bson.Serialization.BsonClassMap' threw an exception. - System.TypeInitializationException: The type initializer for 'MongoDB.Bson.Serialization.BsonClassMap' threw an exception.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'type')
   at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type)
   at MongoDB.Bson.Serialization.BsonClassMap..cctor()
   --- End of inner exception stack trace ---
   at MongoDB.Bson.Serialization.BsonClassMap.LookupClassMap(Type classType)
   at MongoDB.Bson.Serialization.BsonClassMapSerializationProvider.GetSerializer(Type type, IBsonSerializerRegistry serializerRegistry)
   at MongoDB.Bson.Serialization.BsonSerializerRegistry.CreateSerializer(Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at MongoDB.Bson.Serialization.BsonSerializerRegistry.GetSerializer(Type type)
   at MongoDB.Bson.Serialization.BsonSerializerRegistry.GetSerializer[T]()
   at MongoDB.Driver.MongoCollectionImpl`1..ctor(IMongoDatabase database, CollectionNamespace collectionNamespace, MongoCollectionSettings settings, ICluster cluster, IOperationExecutor operationExecutor)
   at MongoDB.Driver.MongoDatabaseImpl.GetCollection[TDocument](String name, MongoCollectionSettings settings)
   at EventFlow.MongoDB.SnapshotStores.MongoDbSnapshotPersistence.GetSnapshotAsync(Type aggregateType, IIdentity identity, CancellationToken cancellationToken)
   at EventFlow.Snapshots.SnapshotStore.LoadSnapshotAsync[TAggregate,TIdentity,TSnapshot](TIdentity identity, CancellationToken cancellationToken)
   at EventFlow.Snapshots.SnapshotAggregateRoot`3.LoadAsync(IEventStore eventStore, ISnapshotStore snapshotStore, CancellationToken cancellationToken)
   at EventFlow.Aggregates.AggregateStore.LoadAsync[TAggregate,TIdentity](TIdentity id, CancellationToken cancellationToken)
   at EventFlow.Aggregates.AggregateStore.<>c__DisplayClass11_0`3.<<UpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at EventFlow.Core.TransientFaultHandler`1.TryAsync[T](Func`2 action, Label label, CancellationToken cancellationToken)
   at EventFlow.Aggregates.AggregateStore.UpdateAsync[TAggregate,TIdentity,TExecutionResult](TIdentity id, ISourceId sourceId, Func`3 updateAggregate, CancellationToken cancellationToken)
   at EventFlow.CommandBus.ExecuteCommandAsync[TAggregate,TIdentity,TResult](ICommand`3 command, CancellationToken cancellationToken)
   at EventFlow.CommandBus.PublishAsync[TAggregate,TIdentity,TResult](ICommand`3 command, CancellationToken cancellationToken)

I reverted your commit, you can create a new pull request.

Originally posted by @OKTAYKIR in #4 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.