FAQ Database Discussion Community


Dynamically creating operations and services in ServiceStack

c#,api,command,servicestack,cqrs
I'm working on a ServiceStack project that requires me to gather a list of commands, of which I have over 200, and create a operation and service for each of them. Essentially I am making a Commanding API which will allow users to send commands without using the UI (exposing...

How to return result while applying Command query separation (CQS)

c#,design-patterns,cqrs,command-query-separation
I am separating my query and command on service side like this: public class ProductCommandService{ void AddProduct(Product product); } public interface ProductQueryService{ Product GetProduct(Guid id); Product[] GetAllProducts(); } Command Query Separation accepts that a method should change state or return a result. There is no problem. public class ProductController: ApiController{...

best event sourcing db strategy

mysql,cqrs,event-sourcing
I want to setup an small event sourcing lib. I readed a few tutorials online, everything understood so far. The only problem is, in this different tutorials, there are two different db strategies, but without any comments why they use the one they use. So, I want to ask for...

Who is responsible for entity's mutation when domain event is raised? DDD

c#,domain-driven-design,cqrs,servicebus,domain-events
I've been learning about CQRS/ES. Looking at small example projects I often see events mutating the entity state. For instance If we look at the Order aggregate root: public class Order : AggregateRoot { private void Apply(OrderLineAddedEvent @event) { var existingLine = this.OrderLines.FirstOrDefault( i => i.ProductId == @event.ProductId); if(existingLine !=...

CQRS + ES shall we persist commands and queries?

cqrs,event-sourcing
Tipically commands are used by handlers to modify aggregates state and emit events which get persisted to event store. But depending on business logic today we might have some events emitted and some not tomorrow... I wonder if this means that commands shall be persisted as well? Whats your experience...

What properties on Department domain entity for CQRS

domain-driven-design,cqrs
I'm trying out in CQRS for the first time and need some advice. In my business, a department can be renamed. To do this, I dispatch a RenameDepartment command, caught by a command handler. This handler will then invoke the rename method on the Department entity, should this do anything...

Handling large amounts of denormalized read model updates in CQRS

mongodb,cqrs,event-sourcing
I'm designing a CQRS event-sourced system (not my first) where my read models are denormalized and stored in a read-optimized document database (MongoDb). Nothing special. Now this particular read model, is a document that contains a user id and a potentially large array of groups that the user is a...

Parallelism and Failover of a Sequential Data

java,distributed-computing,cqrs,failover,xa
Good time guys! We have a pretty straightforward application-adapter: once in 30 seconds it reads records from a database (can't write to it) of one system, converts each of these records into an internal format, performs filtering, encrichment, ..., and, finally, transforms the resulting, let's say, entities into an xml...

Mapping between JPA entity and DTO in CQRS

java,jpa,cqrs,data-transfer-objects
I am looking to use CQRS in a project I'm working on, however I'm currently struggling with the best way to implement the query side of CQRS. Based on my somewhat limited understanding there is a Thin Data Layer (sometimes called a Thin Read Layer) which queries the database and...

What should be returned from the API for CQRS commands?

rest,http,design,cqrs
As far as I understand, in a CQRS-oriented API exposed through a RESTful HTTP API the commands and queries are expressed through the HTTP verbs, the commands being asynchronous and usually returning 202 Accepted, while the queries get the information you need. Someone asked me the following: supposing they want...

CQRS/ES - do I understand It correctly?

events,cqrs
I would like to sum my knowledge about CQRS/ES. I started to read about this subject some time ago and because of I'm young developer I don't understand every aspect of that concept. I will try to describe my understanding of CQRS on some example flow. So defining general steps...

How to do pagination in cqrs

pagination,cqrs,event-sourcing
I am just started learning CQRS model. So when an action performed on a domain I store that action as event in DB, without updating actual domain. So, I understand that on read side I have to prepare read model by applying all events of given domain and return to...

How to model a warehouse application with DDD/CQRS/ES?

domain-driven-design,cqrs,event-sourcing
We want to model a warehouse application. Let us assume we identified the following real world objects: Articles(the things stored in the warehouse) Palettes (where the Articles are on) Compartments (the places in the racks where the palettes are stored in) There are the following constraints: A palette is in...

CRQS : benefits of queuing commands

php,message-queue,cqrs
I can't really understand the benefit of queuing commands in a CommandBus. Here is my very simple implementation of a CommandBus : class CommandBus implements ICommandBus { private $handlerLocator; public function __construct(ICommandHandlerLocator $handlerLocator) { $this->handlerLocator = $handlerLocator; } public function handle(ICommand $command) { $handler = $this->handlerLocator->getHandlerInChargeFor($command); try{ $handler->handle($command); } catch(\Exception...

CQRS and REST HATEOAS mismatch

rest,domain-driven-design,cqrs,hateoas
Suppose you have a model Foo. One business case is to simply create an instance of Foo, so there is a corresponding CreateFooCommand in my model, triggered by invoking a POST request to a given REST endpoint. There are of course other Commands too. But now, there is a ViewModel,...

Dealing with queued command handler response. CQRS

c#,domain-driven-design,messaging,cqrs,masstransit
Consider the situation: public class OrderController { IBus bus; public OrderController(IBus bus) { this.bus = bus; } public ActionResult Checkout(String orderId) { var command = new CheckoutOrderCommand(orderId); bus.Send(command); return Redirect("on-success-url"); } } The corresponding command handler (defined in a separate assembly) is awaiting for the incomming message to be processed....

How to handle MixedQuery with CQRS?

architecture,cqrs,event-sourcing
In properly deisgned application it might be that you can separate all requests to commands (that only update aggregates and return void) and queries (that extract data from specific read optimized model). But if you already have a heavy application and want to slowly move it to ES + CQRS...

Command Pattern in GOF vs CQRS meanings

design-patterns,cqrs,command-pattern
When Looking at the command pattern a found a slight difference. May be some is able to more clearify this. When looking at Gang Of Four it says that each command has a Execute Method see for example: http://www.blackwasp.co.uk/Command.aspx like: myCommand.Execute(myValue); Now when i look at the commands how there...

CQRS and calculations

architecture,cqrs
I am currently working on some proof-of-concept code that follows the CQRS pattern and I cannot find a satisfactory solution to a problem I [think I] have. The system calculates the impact of market changes against a given portfolio based on specific scenarios. Portfolios can contain from one to several...

CQRS and WebSockets

architecture,websocket,web-deployment,cqrs,event-driven
When we have to add push updates feature to a system based on CQRS, it seems that make sense let the "read" model to be responsible of manage those push messages. This make a lot of sense when long polling and server events were used (mostly unidirectional) But WebSockets are...

CQRS : Injecting a messageBus in CommandHandlers

php,messaging,cqrs
Does it sound like a correct approach to inject the whole Bus in commandHandlers so the latter could call $this->messageBus->dispatch($events); class OneCommandHandler { private $messageBus; //..... public function handle(Command $command) { //..... will at some points hopefully returns DomainEvents } private function dispatch(DomainEvents $events) { $this->messageBus->dispatch($events); } } Isn’t it...

Where does FindAndModify fit into CQRS?

c#,mongodb,cqrs
In my current application, I have the following MongoDB FindAndModify call to the MongoDB server public static TEntity PeekForRemoveSync<TEntity>(this MongoCollection<TEntity> collection, string reason) where TEntity : class, IEntity, IUpdatesTrackable, ISyncable, IDeletable, IApprovable { if (reason == null) { throw new ArgumentNullException(nameof(reason)); } IMongoQuery query = Query.And( Query<TEntity>.EQ(e => e.SyncInfo.IsDirty, true),...

Domain Model with Event Sourcing

.net,design-patterns,cqrs,event-sourcing,event-driven-design
Silly question...but why do I need a Domain model at all if I use event sourcing. I have (an Event Bus of course) and Application Services with business operations that each send a Command after basic validation Command Handlers which receive Commands perform additional Command validation and publish Events Event...