I’m building a system which must have a queue and a kind of consumer, that will consume the events of the queue and remove them only if succeeds.
I’m thinking about model the queue and the consumer as different gen servers:
Queue process: Handle insert, get first event and delete operations
Consumer process: Handle consume operation (series of steps over the event data, which may fail)
Both processes have a 1:1 relationship, which means a specific queue has only one consumer and the consumer only consumes from one queue.
The consumer will call it self periodically, requesting to consume an event! This processes consist in a series of calls to the queue process, ultimately removing the event from the queue.
I’m currently thinking about some decisions:
1 - Would be useful to separate the registration of both process under two different Registry?
2 - Since consumer do not make sense without a queue, and the consumer can crash more easily, I was thinking if the Queue process could supervise the consumer process, thoughts on this?
How would you guys solve it, have some repository which implements something similar?