cqrs

In CQRS, how do you build the response when creating an entity?

纵然是瞬间 提交于 2019-12-01 04:45:49
If using CQRS and creating an entity, and the values of some of its properties are generated part of the its constructor (e.g. a default active value for the status property, or the current datetime for createdAt ), how do you include that as part of your response if your command handlers can’t return values? You would need to create guid before creating an entity, then use this guid to query it. This way your command handlers always return void. [HttpPost] public ActionResult Add(string name) { Guid guid = Guid.NewGuid(); _bus.Send(new CreateInventoryItem(guid, name)); return RedirectToAction

Handling out of order events in CQRS read side

早过忘川 提交于 2019-11-30 18:29:41
I've read this nice post from Jonathan Oliver about handling out of order events. http://blog.jonathanoliver.com/cqrs-out-of-sequence-messages-and-read-models/ The solution that we use is to dequeue a message and to place it in a “holding table” until all messages with a previous sequence are received. When all previous messages have been received we take all messages out of the holding table and run them in sequence through the appropriate handlers. Once all handlers have been executed successfully, we remove the messages from the holding table and commit the updates to the read models. This

CQRS and REST HATEOAS mismatch

旧城冷巷雨未停 提交于 2019-11-30 17:50:00
问题 Suppose you have a model Foo. One business case is to simply create an instance of Foo, so there is a corresponding CreateFooCommand in my model, triggered by invoking a POST request to a given REST endpoint. There are of course other Commands too. But now, there is a ViewModel, which is derived from my DomainModel. It's simply a sql table with raw data - each Foo instance from DomainModel has corresponding derived ViewModel instance. Both have different IDs (on DomainModel there is a

Architecture: simple CQS

空扰寡人 提交于 2019-11-30 12:45:49
问题 I'm thinking about applying CQS for my ASP.NET MVC web site, but in a very simple matter. I don't mean CQRS, because I want to use the same data source for query and command parts, and so I don't need event sourcing and other more complex patterns. So, what I have in mind is: use the same database for query and command part for the query part, expose database views with entity framework and WCF data services, so that specific views are returned to the client, querying data becomes very easy

Why limit commands and events to one aggregate? CQRS + ES + DDD

﹥>﹥吖頭↗ 提交于 2019-11-30 12:23:28
问题 Please explain why modifying many aggregates at the same time is a bad idea when doing CQRS, ES and DDD. Is there any situations where it still could be ok? Take for example a command such as PurgeAllCompletedTodos. I want this command to lead to one event that update the state of each completed Todo-aggregate by setting IsActive to false. Why is this not good? One reason I could think of: When updating the domain state it's probably good to limit the transaction to a well defined part of the

Why is the CQRS repository publishing events, not the event store?

自闭症网瘾萝莉.ら 提交于 2019-11-30 12:16:16
问题 According to http://cre8ivethought.com/blog/2009/11/12/cqrs--la-greg-young the component responsible for publishing events using an event publisher is the repository. My question simply is: Why is that? In this blog post we are told that: The domain repository is responsible for publishing the events, this would normally be inside a single transaction together with storing the events in the event store. I would have expected this as a task of the event store: Once an event (or multiple events

How granular should a domain event be?

大城市里の小女人 提交于 2019-11-30 11:51:41
I am wondering how granular should a domain event be? For example I have something simple, like changing the firstName, the secondName and the email address on a profile page. Should I have 3 different domain events or just a single one? By coarse grained domain events when I add a new feature, I have to create a new version of the event, so I have to add a new event type, or store event versions in the event storage. By fine grained domain events I don't have these problems, but I have too many small classes. What do you think, what is the best practice in this case? What's the problem with

GUI recommandations for eventual consistency?

青春壹個敷衍的年華 提交于 2019-11-30 11:34:29
When using distributed and scalable architecture, eventual consistency is often a requirement. Graphically, how to deal with this eventual consistency? Users are used to click save, and see the result instantaneously... with eventual consistency it's not possible. How to deal with the GUI for such scenarios? Please note the question applies both for desktop applications and web applications. PS: I'm working with the Microsoft platform, but I imagine the question applies to any technology... A Task Based UI fits this model great. You create and execute tasks from the UI. You can also have

Implementing Generic Interface in Java

女生的网名这么多〃 提交于 2019-11-30 11:21:42
问题 I have a Java generics question I was hoping someone could answer. Consider the following code: public interface Event{} public class AddressChanged implements Event{} public class AddressDiscarded implements Event{} public interface Handles<T extends Event>{ public void handle(T event); } I want to implement this Handles interface like this: public class AddressHandler implements Handles<AddressChanged>, Handles<AddressDiscarded>{ public void handle(AddressChanged e){} public void handle

best event sourcing db strategy

穿精又带淫゛_ 提交于 2019-11-30 10:20:06
问题 I want to setup a small event sourcing lib. I read a few tutorials online, everything understood so far. The only problem is, in these different tutorials, there are two different database strategies, but without any comments why they use the one they use. So, I want to ask for your opinion. And important, why do you prefer the solution you choose. Solution is the db structure where you create one table for each event. Solution is the db structure where you create only one generic table, and