For axon, does the command handling logic allow you to subscribe
multiple handlers for the same command?
There are some use cases (namely creation & deletion) where having a
single command for two aggregates is useful as each state will
potentially be modified.
Could I represent the entire filesystem as one bounded context? Of
course I could, but I split them up primarily for performance/
scalability concerns, as for clients with large filesystems it is not
reasonable to send & receive the entire contents. ( in an ideal world
client updates would be done via the commands/events themselves, but
that's not possible when connectivity is not guaranteed)
I guess my question is a philosophical one, in CQRS events are tied to
an aggregate, in Axon commands are tied to an aggregate as well.
Should they be? And of course we get to the age old question of
defining just what bounded in "bounded context" means... for your
context! :)
In thinking about this, one potential solution would be to have an
event listener that consumes the file events, and then fires a
"touched file on filesystem" event. The only problem I would see with
this is the guarantee of the event storing properly (command ==
transactional boundary via UOW).
Either way, I've worked around these issues for my current
application, I was just curious to hear everyone's thoughts on this.
The example you provided in regards to flight is an excellent example
of that as well. In the filesystem example, a file is only a
reference (file id), and metadata. For the file aggregate itself,
it's the contents.
Now, on your statement "With scalability, that means you need to
prevent other machines from changing those aggregates in the
meantime", this is where I've been kind of fuzzy with Axon, and CQRS
best practices. Aren't there times, where multiple changes to the
aggregate are possible, or at least not hazardous? If your events are
sequences based upon time, then couldn't you have a basic policy that
states, whatever happened, happened (replay issues aside of course).
I have a use case where clients may be disconnected, yet their state
is still changing, and I want to record this state when connectivity
is resumed. While I could simply state that commands are dispatched
and applied when they arrive, since the client state has already been
recorded by the user, I want to capture their intentions when they
occurred.
My solution was to allow events to be stored at any point in the
aggregate's lifespan (barring before creation). This of course
complicates things on the query side, since you can no longer
guarantee that an incoming event should be applied directly (if it
happened in the past, it may not even need to be applied!). Of
course, barring any business logic constraints, the need to guarantee
that only one instance changes an aggregate at a time tends to disolve
once you remove the requirement that events are sequential moving
forward only.
Thoughts?
I guess from my current thought process, I tend to look at the
aggregates themselves as eventually consistent, and as such, given the
example of two machines working on two commands for the same
aggregate, the events spawned from the actions of the commands will
eventually become consistent when both stored, and then loaded from
the event store.
On Dec 6, 7:13 am, Allard Buijze <bui...@gmail.com> wrote:
> Hi Chad,
>
> let me put my scalability point in perspective. It's absolutely no problem
> to invoke multiple actions *on the same* aggregate at all. This will have
> absolutely no impact on scalability.
>
> The problem lies in the situation where you need to invoke actions on more
> than one aggregate. The reason is simple: to do so, these aggregates need
> to live on the machine that is currently processing the command. If an
> aggregate lives on one machine, it should not live on another, as you can
> get into concurrency problems. Although it's perfectly possible to solve
> these problems, just by retrying. Your performance will drop tremendously
> if you do so, but it will work.
>
> So if scalability is a big requirement, make sure your commands are all
> executable on a single aggregate (i.e. consistency boundary). Side effects
> should be taken care of asynchronously based on new commands (via a Saga,
> for example). These other commands may have to travel to another machine to
> be executed, but it's not a problem anymore.
>
> In other words, it is not so much an event sequencing problem. It is a data
> "Availability" / "Consistency" (see CAP theorem) problem.
>
> Cheers,
>
> Allard
>
On Dec 7, 2:41 am, Allard Buijze <bui...@gmail.com> wrote:
> Hi Chad,
>
> ...
>
> read more »