Seikho / evtstore

Event Sourcing and CQRS with Node.js and TypeScript
https://seikho.github.io/evtstore
62 stars 5 forks source link

Does multiple instances of event handler prevent that events will be processed with correct order? #16

Open gtsamtsouris opened 1 year ago

gtsamtsouris commented 1 year ago

Does multiple instances of event handler ensure that events will be processed with correct order?

Seikho commented 1 year ago

Hi

You should ensure that only one instance of an event handler is processing events. In my own apps I use database locks to guarantee this.

jbalatero commented 4 months ago

Hi @Seikho, I'd like to explore more on the use of database locks. How did you implement this? or any pointers on what I have to research more on this. Thank you. I've used your library in production.

Seikho commented 4 months ago

What database are you using? I mostly use Postgres and MongoDB and have a mutex implementation for both.

jbalatero commented 4 months ago

Thanks for the reply, I'm using MySQL 8

Seikho commented 4 months ago

I'd start by doing something like this: https://github.com/n8j1s/node-mysql-semaphore/blob/master/lib/mysql-semaphore.js