Answer the question
In order to leave comments, you need to log in
What is the best way to organize command management/informing about the result in the CommandBus?
Hello. Trying to figure out CQS, Command Bus and all that. I am writing a pet project to calculate KPI.
Divided everything into Command and Query - everything seems to be ok.
Current Command:
SyncVersions
SyncVersionTasks(VersionId)
SyncTaskHistory(TaskId)
CalclulateKPI(VersionId)
Questions arose:
1) how best to manage the fact that SyncVersionTasks(VersionId) should trigger on each task SyncTaskHistory(TaskId), and after history synching for all tasks should work CalculateKPI?
The first part is currently solved by the fact that SyncVersionTasks publishes the TaskSynced event with TaskId for each task, and the listener dispatches the SyncTaskHistory(TaksId) command to the CommandBus. But how to get involved in the fact that you need to dispatch CalculateKPI exactly after the whole story is pulled up?
2) The user needs a button in the UI - update KPI, which entails the execution of SyncVersionTasks(VersionId) => SyncTaskHistory(TaskId) * N tasks => CalclulateKPI(VersionId).
How to notify the user that the KPI has been recalculated? Forwarding on all commands/events user id seems like a crazy idea. While I see the option:
- display a pop-up to the user - KPI recalculation is running
- write the user id to the radish / cache and that he is waiting for the KPI recalculation
- display on the page who launched the KPI recalculation, when
- in the CalculateKPI handler, throw the KPICalculated event, in the listener of which take data from the cache => send a notification to the user => delete the cache
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question