Client using Command Bus to send commands vs calling Application Services

StackOverflow https://stackoverflow.com/questions/21171627

  •  28-09-2022
  •  | 
  •  

Question

Is my understanding of different ways commands can be delivered to CQRS-based application correct:

1) A CQRS application can receive commands in two ways:

a) either it implements a Command Bus, in which case client puts a command into a Command Bus and sends it to the server or it implements "regular" Application services, which client can then call?

2) If instead of using a Command Bus client can send a command by simply calling Application Service, then this would suggest Command Bus is just an implementation detail of CQRS and thus CQRS may be implemented without it?

3) If CQRS application is using a Command Bus, then couldn't we argue that in that case Application Services exist in the form of Command Handlers?

4) If client doesn't use Command Bus, but instead calls a regular Application Service, then it is a responsibility of a called Application service to create a command object and delegate it to the appropriate command handler?

thanks

Était-ce utile?

La solution

You're confusing things, CQRS simply means have at least 2 models: one for writes (commands) and at least one for reads (query). That's it. If you want to us a service bus is ok, calling directly a service is ok as well. CQRS is the concept, how you want to implement it is up to you

Autres conseils

Just a guess:

The command bus is an techonology strategy that is used to decouple client from command handlers. In this case, on the client side, all we need is just a simple interface.

Command handlers with a bus and app services are just 2 flavors of the application layer API.

Application service is a "classic" approach while command handlers is a design created with a distributed environment in mind (you can add multiple nodes for handling heavy/heavily used commands).

Neither two are directly related with CQRS.

Command bus is just a layer of abstraction and makes it simpler for the client to just use one interface: $commandBus->dispatch($command);

Example of the application service without the command bus: https://github.com/VaughnVernon/IDDD_Samples/tree/master/iddd_collaboration/src/main/java/com/saasovation/collaboration/application/forum

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top