Comments (6)
GenEvent was not suitable for a few reasons.
- For command dispatching in CQRS there must be exactly one registered handler for each command. Not having a handler, or more than one, configured is an error. This is enforced by the Commanded
Router
macro. - GenEvent doesn't guarantee delivery of events. If a subscriber process goes down, it will miss any events published until it restarts. This is the main reason that it is unsuitable.
- All GenEvent handlers run in a single process.
In comparison, each Commanded event handler has its own subscription to the event store. It acknowledges every event it receives and successfully processes. This allows it to resume in the event of a process crash, or catch up if it is lagging behind. It also allows new subscribers to be added and they can receive every event published from the event stream origin. Event handlers run concurrently and are independently supervised. So a problem with one does not affect any other.
from commanded.
Got it, it's an elegant design 💯
For the reason 1, it's okay, the developer can pay attention if the system is small, and if the system is too big, a consistency test tool can track commands, events and errors, and alert if they are inconsistent with the CQRS rules, or if some command was lost and no event or feedback was emitted. For the reason 2 and 3, seems that GenStage comes to solve them: http://elixir-lang.org/blog/2016/07/14/announcing-genstage/ . Please, let me know if makes sense.
from commanded.
GenStage could be useful for event handling. I've taken a look at it before. Its approach to broadcast is to wait for every subscriber. This may not be appropriate if you have independent event handlers that you don't want to be blocked by the slowest handler. Back pressure has already been implemented for Commanded's event handlers.
from commanded.
I think that GenStage producers can provide input for any consumer that requests demand.
Besides, there is an experimental PartitionDispatcher which makes a lot of sense for event sourcing.
from commanded.
For the record, I have read at least a couple of articles advising against using gen_event.
from commanded.
Yep, also read, seems we should avoid it.
from commanded.
Related Issues (20)
- Update sponsors in BACKERS and README HOT 1
- General design philosophy question: sending email from process manager HOT 4
- update FAQ regarding scheduling HOT 1
- Wiki Testing section is outdated HOT 1
- warning: redefining module Commanded.Serialization.JsonDecoder.Any HOT 2
- Event number gaplessness required?
- Commanded.aggregate_state does not work when aggregate identity has a prefix HOT 10
- Process manager router option not working
- Lessons learned from performance optimization - an unlikely culprit HOT 3
- no function clause matching in Commanded.Commands.Dispatcher.telemetry_stop/3 HOT 1
- Docs questions
- Stacktrace in event handler error? HOT 2
- Paralelization Strategies in EventHandlers
- Should Commanded.Event.Handler support messages from swarm? HOT 2
- Event retention policies?
- please support multiple commanded application with one eventstore HOT 6
- Process Manager state serialization breaks when using a custom TypeProvider with the JsonSerializer
- `Commanded.ProcessManagers.ProcessManager.identity/0` function returns `nil` in unit tests
- no function clause matching in Commanded.Event.Handler.partition_event/4 HOT 1
- EventstoreDB is sunsetting the TCP protocol HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commanded.