Comment by airocker
1 year ago
We use listen notify extensively and it is great. The things it lacks most for us is guaranteed single recipient. All subscribers get all notifications which leads to problems in determining who should act on the message n our case.
Could use the notify to awake, and then the worker needs to lock the job row? Whichever worker gets the lock, acts on the message
Thats exactly what we do but taking a lock takes 1 RTT to the database which means about 100ms. it limits the number of events receivers can handle. IF you have too many events, receivers will be just trying to take a lock most of the time.
Of my head, you could attach a uuid or sequence number to the emitted event. Then based on the uuid or sequence you can let one or the other event consumer pick?
Ex. you have two consumers, if the sequence number is odd, A picks it, if its even B picks.
4 replies →
Wouldn't it be possible for you to lose jobs if no subscriber is listening?
We use a garbage collector to error restart if a job is not served within a specified amount of time.