Re:Don't Use an RDBMS for Messaging
by lobster_johnson on Saturday September 27, 2014 @07:45PM
(#8378496)
Oops, my mistake. That's actually disappointing, since it means that for every message, N workers will all wake up and needlessly try to grab the message.
You can get around that by using advisory lock to make access exclusive, but they will still all wake up and will still have issue a select.
Re:Don't Use an RDBMS for Messaging
by empthought on Sunday September 28, 2014 @03:20PM
(#8380653)
Why not have N channels for N listeners? These are very lightweight (no persistence/retry, etc. -- essentially just a way to avoid SELECT polling by consumers).
Re:Don't Use an RDBMS for Messaging
by lobster_johnson on Sunday September 28, 2014 @04:27PM
(#8380818)
That ties the channel names to the number of listeners, which opens you up to race conditions when the pool of workers changes. And you would have to keep track of which channels aren't busy at any given time, in order to avoid waking up busy workers that can't accept a job. Not impossible, just more stuff that could go wrong.
Re:Don't Use an RDBMS for Messaging
by empthought on Sunday September 28, 2014 @08:30PM
(#8381294)
I think you're right, that would need to be built into whatever job management logic you implemented before the notification was sent. This type of architecture is more suitable for a workflow or job management system rather than fanning out data processing to N workers.
http://www.postgresql.org/docs/9.3/static/sql-notify.html