Questions tagged [cqrs]
Command Query Responsibility Segregation design pattern
297
questions
1
vote
2
answers
306
views
In DDD, how can repositories be optional?
I was reading the infrastructure persistence layer design documentation, and this quote has me confused:
This'll probably be my biggest feedback. I'm really not a fan of repositories, mainly because ...
1
vote
1
answer
167
views
How to handle aggregations of out-of-order events in an event stream?
I'm interested in integrating with an external system which uses webhooks to notify clients of events. The system is very similar to Stripe - the REST endpoints have rate limits to avoid undue polling ...
0
votes
3
answers
319
views
Is CQRS CQRS without separate read and write data stores?
Is having a separate read only and write only data store a core part of CQRS, or does it still make sense in some scenarios to do CQRS with a single data store?
Asking because a coworker is using CQRS ...
1
vote
1
answer
98
views
Design considerations for data shared across multiple users: is Redis a good candidate?
I have an app that has an assets table like the following:
user_id
code
current_price
1
ALUP11
12.5
2
ALUP11
11.9
user_id and code are unique together and current_price is updated if the user ...
1
vote
2
answers
209
views
Using multiple databases in a bounded context
Sometimes we have to use multiple databases in one project
with the intentions of:
Denormalizing data or read models
Using the advantages of that database (technology)
There has been a lot of talk ...
1
vote
1
answer
215
views
Reduce Code Repetition for a Simple CQRS
We're currently exploring CQRS in our future applications. To give a bit of a background, we use a simple CRUD-style service before something like this.
Old Pattern:
Controller
Command/Service
Model
...
2
votes
3
answers
381
views
What should we do in face of a failing sub in pub-sub?
I'm working on a microservices application that is implemented from the ground up with MediatR em CQRS. We have a list of domain events that will be published via MediatR [simple pub-sub library that ...
0
votes
0
answers
91
views
Can Apache Pinot be used as a general purpose read model?
It's clear that Apache Pinot is intended to be used as an analytics datastore but I can't seem to find anything that explains why it can't be used as a general-purpose read model.
For instance, let's ...
1
vote
2
answers
224
views
CQRS and events order
I'm learning cqrs right now.
Problem
My concern is event ordering.
Assumption 1: user service is creating user and three events in order.
Each event was sent after each step was finished in write ...
0
votes
0
answers
51
views
Is CQRS applicable with total ordered views and sharding?
Merry Christmas everybody.
I am trying to solve a theoretical sharding problem out of my own curiosity and I think CQRS can help me achieve properties that I want of my data.
I have too much data for ...
1
vote
1
answer
1k
views
Best practices repository and service layer
I have read many articles about repository pattern and service layer but I have still some doubts in certain arguments:
Repository should return only aggregates and I should have repositories only ...
1
vote
1
answer
234
views
How do I make conditional queries within DDD logic
I have created a small ERP application and the architecture I chose included the Repository pattern and the anemic Domain model and Business logic layer.
I was reading Microsoft's guide about ...
0
votes
1
answer
89
views
How is model reconstructed with event sourcing in CQRS principle?
I'm trying to understand the CQRS design.
As far as I know now, every time a change to a model is saved, the (state) change is stored as a separate record.
When reading a model, the model is ...
1
vote
1
answer
194
views
Where should I fetch a product price to create an order in CQRS / DDD?
I want to save an order with order items with prices in my write database. But firstly I need to fetch products with their prices because I don't trust a user - he could pass a lower price, that's why ...
2
votes
1
answer
154
views
Moving from CRUD to CQRS: how to identify appropriate command-event relationships?
We have an existing CRUD-based system, but are hitting a number of pain points keeping the data organised for all the various views that are increasingly required of it. I'm assessing whether ...
2
votes
3
answers
762
views
CQRS in a data heavy application involving a lot of CRUD
I've been developing a non-trivial personal application and I thought I'd use CQRS to learn it. The application is very data entry heavy, lots of entities and lots of forms. I find myself constantly ...
1
vote
1
answer
309
views
Internal/external commands in CQRS
I have several questions related to CQRS in eventually consistent systems with a need of resilient Command/Event processing.
Is it OK to have external/public synchronous Commands (triggered by API, e....
0
votes
1
answer
684
views
Handling asynchronous domain events with multiple handlers & allowing them to fail independently
We're building a service using DDD, CQRS, & Hexagonal Architecture that allows the user to upload a CSV feed for which every row will be transformed and sent to a third party over HTTP.
We have ...
1
vote
2
answers
122
views
Applying Domain Driven Design to applications with both reading and writing heavy logics
We are planning a complete rewrite of a very complex project (10+ years, ~15 different application modules) and we would like to adhere to DDD and CQRS as much as possible but we are struggling to fit ...
2
votes
2
answers
329
views
Relaxing layering rules for queries?
In a typical DDD layered architecture (application, domain & infrastructure layers) you'd generally declare interfaces in the domain/application layers and implement infrastructure-dependent (e.g. ...
0
votes
0
answers
157
views
Avoiding reloading entities many times with EF Core and Mediatr
We have a largeish .NET Core project which uses Mediatr and EF Core. Many of the queries look something like:
public class GetSomeInformation : IRequest<string>
{
public int DocumentId { get;...
2
votes
1
answer
1k
views
How to scale transactional outbox pattern with document database?
I'm trying to understand CQRS, DDD by writing a small pet project which is somewhat similar to this great repo.
I've come across Transactional Outbox pattern and as imo it was correctly pointed out in ...
1
vote
1
answer
137
views
Tight coupling between micro services
I have got the following scenario, which I have been thinking what would be the "best" way to solve it.
Request comes from the FE, which changes the status of a delivery,
and that should ...
0
votes
0
answers
133
views
In CQRS, how does the event processor know how to populate the read-side database?
I'm currently playing around with a CQRS implementation and I'm having some trouble understanding the following concept:
Event Bus for publishing update events (required): Whenever the write
database ...
2
votes
3
answers
368
views
How to implement HATEOAS with CQRS?
Let's say I have a CQRS system where my write model contains the business rules. My read model is simply a DTO; it is a collection of properties and "dumb".
Now if you were to create a REST ...
1
vote
1
answer
2k
views
How to handle duplicate validation logic with CQRS pattern
I am implementing a CQRS pattern in ASP.NET Core with MediatR, and I am wondering what the general consensus is for handling duplicate validation logic for queries/commands which operate on the same ...
0
votes
0
answers
488
views
CQRS, DDD and batch, CRUD-y operations
How to perform basic CRUD operations (especially batch) by playing with DDD and CQRS?
Let's say I have a list of IDs in my controller that need to be removed (soft delete). Currently, I treat this ...
0
votes
0
answers
183
views
How to model an event-driven system for replays
Let's say I have a system to which I can upload documents via an API. There are three services:
the UploadService - responsible for providing a HTTP endpoint
the StorageService - responsible for ...
0
votes
3
answers
700
views
Should I perform simple validation (not null, max length, etc.) in a web api controller and duplicate in a command handler?
I have a question about DDD. I wonder if I should add validation in a web api controller and duplicate it in a command handler? Is it good approach to validate a DTO and a command even if the ...
0
votes
0
answers
303
views
.Net Core Api - multiple Dto’s for single entity
I want to know the best Practice is about having multiple dto’s for different use cases.
Let’s say we have an api with a set of controllers to handle requests coming from a administration backend and ...
0
votes
1
answer
255
views
One read model project/microservice for all other bounded contexts - is it a good idea?
I have three bounded contexts: Users (generic subdomain), Groups (supporting subdomain) and Events (core domain). Basically users can create/join groups, create events within those groups, and sign up ...
1
vote
1
answer
190
views
What to improve/change and how to move forward with my Event Storming session?
I'm doing alone session with Event Storming for my application that I plan to build with DDD approach later on. Event Storming session is for learning purposes.
My application domain logic is rather ...
2
votes
2
answers
1k
views
CQRS MediatR Create many items commad - is it a good practise?
I am here to ask question about:
is it good practice to insert many records using CQRS and MediatR?
how to structure that in terms of names and folders?
A have to insert into database over 500 ...
1
vote
4
answers
578
views
Should queries in CQRS be designed based on external demand?
I'm working in a microservice application which has some level of coupling between the microservices (some of them talk with each other via rest api - I know it is bad, but it is what it is; also I ...
0
votes
1
answer
236
views
DDD+CQRS - Should I always check if the Databases are online?
I'm developing an intranet application and I'm trying to use some concepts from Domain Driven Design (DDD) and Command and Query Responsibility Segregation (CQRS) in .NET Core, with EFCore.
But, to ...
0
votes
0
answers
206
views
Saga / Processmanager?
I'm thinking about this scenario:
I can receive customer inquiries by Email.
Those inquiries can be sent from existing customers or unknown "customers" - I'll call latter "Leads".
...
0
votes
1
answer
303
views
Should Commands always be a facade to inner layers in CQRS?
In a DDD-CQRS scenario, should my commands in the Application/Service layer always be just a facade to different aggregation method and other inner layers like repository calls in the infrastructure ...
1
vote
2
answers
1k
views
In CQRS/ES should database calls be done in command handlers or domain models?
In the context of a DDD application following CQRS and the event sourcing pattern, I have 2 questions.
At which layer should the direct calls to the Infrastructure layer be made? At the Application ...
0
votes
2
answers
198
views
May the left-side know the right-side when using CQRS with Hexagonal?
I'm trying to use the hexagonal architecture but I want the flexibility to make CUSTOM queries right to the database (or cache) to populate DTOs right from the left-side without passing through the ...
1
vote
0
answers
439
views
Authorization and Cross-Cutting Concerns in DDD (CQRS) - Filtering Data
We are currently in the early phases of developing several applications that differ significantly in their functionality. As part of building these applications, we have also developed a few generic ...
0
votes
1
answer
124
views
Duplicate Query rest end points in microservices - CQRS
I am a newbie to microservice. Currently I'm learning microservices by creating 2 microservices with CQRS pattern, with NO event sourcing, but each service has separate DB. Each service has separate ...
3
votes
2
answers
659
views
Microservices: Is the Saga Pattern correctly applied here?
I'm trying to understand and learn how to build microservice messages the best and came up with this task for myself:
Services given:
Accounts Service
Token Service
Email Service
When a user ...
1
vote
2
answers
367
views
CQRS: Is it an antipattern if the Command invokes a database interface which contains business logic?
Martin Fowler states that,
Command module executes validations and consequential logic
which aligns with every CQRS demo app that I've studied.
That is to say: validation -- does this Jedi exist? -- ...
3
votes
0
answers
447
views
Implementation of projections in event-sourced system
I'm working on a application which uses event-sourcing and CQRS to define it's domain model.
Background
We have implemented projections to aggregate stream of all domain events into a read models used ...
1
vote
0
answers
255
views
Where does a Process Manager live with a Hexagonal/Ports and Adapters Architecture?
Context: I initially asked this question. I lacked some understanding and phrasing to ask the actual question I wanted to ask. The answer though helped me understand the friction points a bit better ...
1
vote
1
answer
501
views
In CQRS/ES where does an Aggregate Root belong?
Disclaimer: This question may be related to the framework I'm using to support CQRS/ES rather than the concepts themselves but many of these frameworks implement the same strategies, making me think ...
4
votes
3
answers
1k
views
CQRS: getOrCreate - is this a command, query, or both?
Consider the following scenario:
If the user isn't registered in the database, register them. Return their ID.
If the user is in the database, return their ID.
The API endpoint for this may look ...
1
vote
2
answers
411
views
How to manage primary keys in CQRS
I'm building a backend following the CQRS pattern and I don't know how to manage properly the primary keys (surrogate keys) between the command and query databases.
For example: I have a model with ...
1
vote
1
answer
429
views
Does CQRS Handler can invoke another Handler because of relations to another Domain?
I have read DDD Vaughn Vernon book. There is a info about CQRS architecture. He mention that Handler can only do one Handler task, which I understand his and he cannot invoke other Handler. And even ...
0
votes
2
answers
395
views
Is there alternative to applying events synchronously in command handler in CQRS?
I have workflow where I have complex command handlers encapsulated inside aggregate. These handlers emit some events, and then further logic based on result of these events can emit more events. ...