Ensuring synchronous behavior in CQRS when needed?

I use ASP.NET MVC with NServiceBus, and where, since the vast majority of commands can be executed with a possible sequence, there are a small number of tasks in which an immediate sequence can simplify things.

I have done a lot of research on the different methods used for this, but few come with any justification for why this particular method is preferred. I have no experience working with NSBs in a production environment, so it would be nice to know if any methods limit scalability in any way.

The following are the methods I came across: -

  • There is no synchronization, fake information back to the client. My reservations in this case, firstly, you have to deal with the case when you faked the data, and the team failed (an unlikely scenario) and, more importantly, if the initialization of any data inside the team is complex, the ability to fake this data in any case is optional.
  • Reply (or post the event that will be received by the client) when the task is completed. My reservation with this is that this means that the distributed architecture is becoming more complex, and I'm not sure balanced clients can cause problems, since only one of the client computers should receive a response.
  • Interrogate the storage until data is present. My reservation with this is that it puts the read more load store than other options.

Are there any options that are better than the previous three, and if so, why? If not, which of these three is better and why?

I assume that the answer is not subjective, and one can use NServiceBus to implement the command infrastructure in CQRS better than others.

Thanks.

+4
source share
1 answer

I believe that the actual endpoint should not do the work, but pass it to some Application Service / Operation Script object. This object does the job immediately.

Therefore, for cases when you absolutely must have 100% consistency, rather name the same task object rather than send a command for further processing. You can still use this command for other scenarios.

+1
source

Source: https://habr.com/ru/post/1496301/


All Articles