Am 07.02.13 11:35, schrieb bandar:
Hi Martin,
Thanks for reply,
I came to conclusion that eventsourced main purpose is to ability
to restore last actor state after application shutdown/crash using
journaled messages,
and has no relation with cqrs-eventsourcing
architecture.
No. See the
reference
application for an example how 'c'ommands and 'q'ueries can be
separated. As an example, the StatisticsProcessor maintains a read
model (the R in CQRS) that is updated from events emitted by the
InvoiceProcessor. The InvoiceProcessor on the other hand processes
commands and maintains a write model. Therefore, reads about update
statistics and commands for changing invoice state are targeted at
different models, a simple CQRS example.
Since I, and maybe most of us here too, came to eventsourced when
searching for cqrs-eventsourcing framework in scala, i think the
InvoceProcessor example is a bit misleading newbies like me, for
me its more "memory image pattern" implementation rather than
cqrs-eventsourcing implementation, or maybe eventsourced is
coupled tight with "memory image pattern" by design ?
Yes,
the
key element to a memory image is using event sourcing.
Furthermore, nothing prevents you to store read models in a database
instead of in-memory (i.e. store the current state instead of
changes/events). In this case, just make sure that the actor, that
persists the read model, is not modified with the Eventsourced
trait. Nevertheless, the key point to scalability (another important
focus of Eventsourced) are append-only writes to an event log
(journal), whereas update (in-place mutations in a database) may
prevent scalability.
I would like to see eventsourced library usage without memory
image pattern,
Actually, Eventsourced doesn't force actors to store their state in
memory, they can also make updates to a database (in addition to
write received event messages to an event log) or using a hybrid
approach where only part of the application state is kept in memory
e.g. the frequently used part of application state; other parts can
be stored somewhere else and loaded on demand if needed. You have
all the options with Eventsourced.
I believe eventsourced will be shine if used as "saga"
in a cqrs-eventsourcing application but I need to dig it deeper.
There are examples of event sourced business processes (sagas) in
the user guide like the
order
management example. It is also shown how to implement event
sourced
state
machines which are a good basis for long-running, persistent
business processes.
Cheers,
Martin