rethabile
rethabile

Reputation: 3199

one event triggering another command in CQRS

I need some opinions/suggestions/recommendation on this one.

I have this use case where 1 event can trigger another command in a CQRS.

The scenario is, there is 1 command service and 2 subscriber/query services and 1 of the subscribers need to perform some search and based on the result of the search can issue another command.

Now, the question is should the query service issue a command (direct to eventstore: I guess this defeat the purpose of cqrs) or make a normal api call to the command service (perhaps via api gateway) which will issue the command?

Upvotes: 2

Views: 572

Answers (1)

Alessandro Santini
Alessandro Santini

Reputation: 2003

I would not model a query as a Command first of all, and I would not target the EventStore, as you correctly pointed out.

The query targets one of the many possible read models that you generate from the event store.

If the query issues a command, it is not a query anymore, it becomes as service; therefore, in that case, you should be invoking a service.

Hope that makes sense and good luck with your project.

Upvotes: 3

Related Questions