Alexander Petrov
Alexander Petrov

Reputation: 9492

Command pattern - How to preserve execution state?

I have the folowing opertaion. I need to create a reservation, during the create of reservation I need to orchestrate several things. The reservation is ordered through a third party system, then an e-mail is sent , then a price offer is finalized and so on...

Can I encapuslate this logic in a single CreateReservationCommand or I need to have three commands and then what pattern would orchestrate the command execution ? Can a command has execution state at all ?

Also I have the feeling that the Command in the sense of gang of four is different than the Command in the sense of CQRS for example. Am I right ?

UPDATE:

What makes me confused here is that in terms of CQRS you can have a commands and events and lets supposed that third party system sends a message to my system CREATE_RESERVATION wouldn't this in the context of CQRS be a command and yet this is more of a complete workflow probably SAGA pattern ?

Upvotes: 1

Views: 109

Answers (1)

VoiceOfUnreason
VoiceOfUnreason

Reputation: 57239

Can I encapuslate this logic in a single CreateReservationCommand or I need to have three commands and then what pattern would orchestrate the command execution ? Can a command has execution state at all ?

You can... but usually the book keeping of orchestration uses something like the process manager pattern, which would span multiple transactions.

I have the feeling that the Command in the sense of gang of four is different than the Command in the sense of CQRS for example. Am I right ?

You are absolutely correct -- completely different ideas. "Command in CQRS" is a descendant of Gregor Hohpe's Command Message pattern.

Upvotes: 3

Related Questions