boase / be.cqrs Goto Github PK
View Code? Open in Web Editor NEWProduction implementation of the common domain object repository pattern in a CQRS context
License: MIT License
Production implementation of the common domain object repository pattern in a CQRS context
License: MIT License
public sealed class CustomerOriginState : StateBase
{
public void On(IOriginEvent @event) {}
}
public interface IOriginEvent : IEvent
{
string Origin { get; }
}
Denormalizer doesn't work if the following order is changed to:
await app.UseRealms();
await app.UseDenormalizer();
instead of:
await app.UseDenormalizer();
await app.UseRealms();
See services.TryAdd...
Replace obsolete MongoDb collection.Indexes.CreateOneAsync
usages and use CreateIndexModel
instead.
Create BaseCommandHandler from Interface
Currently, the full name of the domain object including namespace is persisted. Allow moving or renaming the domain object while keeping backward compatibility, e.g. by providing a mapping from old full name to new full name, either in the configuration or in an attribute.
[xUnit.net 00:00:01.1304280] BE.CQRS.Domain.Tests.DomainObjectTests.Visiting.WhenVisiting.ItProcessedAppliedAndUncommittedEvents [FAIL]
[xUnit.net 00:00:01.1365290] BE.CQRS.Domain.Tests.ConventionEventhandlerTests.WhenEventIsRaised.ItCallsTheMethod [FAIL]
Failed BE.CQRS.Domain.Tests.DomainObjectTests.Visiting.WhenVisiting.ItProcessedAppliedAndUncommittedEvents
Error Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at BE.CQRS.Domain.DomainObjects.DomainObjectBase.StateInternal[T](Boolean excludeUncommitted) in /Users/alexzeitler/src/github.com/BE.CQRS/src/Domain/Domain/DomainObjects/DomainObjectBase.cs:line 195
at BE.CQRS.Domain.DomainObjects.DomainObjectBase.State[T]() in /Users/alexzeitler/src/github.com/BE.CQRS/src/Domain/Domain/DomainObjects/DomainObjectBase.cs:line 185
at BE.CQRS.Domain.Tests.DomainObjectTests.Visiting.WhenVisiting..ctor() in /Users/alexzeitler/src/github.com/BE.CQRS/src/Domain/Domain.Tests/DomainObjectTests/Visiting/WhenVisiting.cs:line 26
Failed BE.CQRS.Domain.Tests.ConventionEventhandlerTests.WhenEventIsRaised.ItCallsTheMethod
Error Message:
System.ArgumentNullException : Value cannot be null.
Parameter name: logger
Stack Trace:
at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
at Microsoft.Extensions.Logging.LoggerExtensions.LogTrace(ILogger logger, String message, Object[] args)
It should be possible to optin into logging messages i.g. to print them to the console
Idea:
return Id via Location
-Header in 202 Accepted
response.
Goals:
CommandBus
usage@BoasE Is folder name 2_ASPNET_Core/AspNetCoreSample
ok?
When using Denormalizers, there's an extensive logging of
had work
no work
no work
no work
Given this Customer class:
public sealed class Customer
{
[BsonId]
public ObjectId Id { get; set; }
public string Name { get; set; }
}
And this Repository:
{
private readonly IDenormalizerContext context;
public CustomerRepository(IDenormalizerContext context) : base(context.Db, "Customer")
{
this.context = context;
}
public Task AddCustomer(string customerId)
{
var dto = new Customer
{
Id = new ObjectId(customerId)
};
return Collection.InsertOneAsync(dto);
}
}
When debbuging in Rider, I get this exception:
System.FormatException: String should contain only hexadecimal digits. at MongoDB.Bson.BsonUtils.ParseHexString(String s) at MongoDB.Bson.ObjectId..ctor(String value) at AspNetCoreSample.Denormalizer.Repositories.CustomerRepository.AddCustomer(String customerId) in /home/alexzeitler/src/github.com/BE.CQRS-15/Samples/3_ASPNET_Core_ReadModels/AspNetCoreSample.Denormalizer/Repositories/CustomerRepository.cs:line 18 at AspNetCoreSample.Denormalizer.CustomerDenormalizer.On(CustomerCreatedFromApiEvent event) in /home/alexzeitler/src/github.com/BE.CQRS-15/Samples/3_ASPNET_Core_ReadModels/AspNetCoreSample.Denormalizer/CustomerDenormalizer.cs:line 26
But the application does not log any errors on console.
Windows: net462
macOS/Linux: netstandard2.0
.net 4.6.1 or lower support
Create a possibility to run the denormalizers in a way so that they are called right after saving the event. This way the usage of a messagebus cam be omitted.
This will then make it required to have a simple possibility to run the creation of the read database
Remove Ordinal
property on EventCommit
- duplicates functionality
This would allow to e.g. implement a Enricher
(outside BE.CQRS) which handles correlation id and passing the Enricher
to the config, the correlation id would also be used in BE.CQRS, thus it wouldn't be a black box correlation logging wise.
Create a Sample showing how delete works in CQRS
New name: 1_NET_Core/NetCoreConsoleSample
When inserting events into the repository, the generated logs use the a Type
property:
MongoCommitRepository
Line 194
logger.LogError(e, "Error when saving a commit for {type} {id}", commit.AggregateType, commit.AggregateId);
and Line 203
logger.LogDebug("{Count} events for {Type} - {Id} handled. Result: {Result}.", commit.Events.Count, commit.AggregateType, commit.AggregateId, result.CommitId);
When using structured logs, the Type
property is usually already in use by some data processing pipelines, in this particular Logstash, which then can cause errors.
Rename the Type
property to AggregateType
to prevent such conflicts
If a create command is missing a domain object id, the command just get lost.
There is no exception nor a new id with aggregate ist created
If applyConfig
on DomainObjectBase
is not called, theres no
StateActivator` set which causes NullRefExceptions.
new EventSourceConfiguration()
.SetDomainObjectAssemblies(typeof(RealmDomainObject).Assembly)
.SetDomainObjectAssemblies(typeof(LocalizationDomainObject).Assembly) // <= duplicate assembly
.SetServiceProviderActivator()
Issue appears repeatedly and with no recognisable pattern so far. The stacktrace is the following:
[11:14:09 ERR] Error handling command "Csi.Identities.Commands.AddPhoneCommand" - '' is not a valid 24 digit hex string.
System.FormatException: '' is not a valid 24 digit hex string.
at MongoDB.Bson.ObjectId.Parse(String s)
at MongoDB.Bson.BsonTypeMapper.Convert(Object value, Conversion conversion)
at MongoDB.Bson.BsonTypeMapper.MapToBsonValue(Object value, BsonType bsonType)
at MongoDB.Bson.BsonObjectId.Create(Object value)
at BE.CQRS.Data.MongoDb.Commits.MongoCommitRepository.ByInternalId(String commitId)
at BE.CQRS.Data.MongoDb.MongoDomainObjectRepository.ByAppendResult(AppendResult result)
at BE.CQRS.Domain.DomainObjectRepositoryBase.SaveAsync[T](T domainObject, Boolean preventVersionCheck)
at BE.CQRS.Domain.Conventions.ConventionCommandInvoker.InvokeAndSaveInternalAsync(Type domainObjectType, ICommand cmd, IEnumerable`1 commands)
at BE.CQRS.Domain.Conventions.ConventionCommandInvoker.InvokeAndSaveAsync(Type domainObjectType, ICommand cmd, IEnumerable`1 commandMapping)
at BE.CQRS.Domain.Commands.InMemoryCommandBus.HandleCommand(ICommand cmd)
if B is derived from A then the following method in a state would be triggert
void On(A @event)
To make a more easy way we can link the examples from the readme
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.