Re: NOTIFY/LISTEN on server, asynchronous processing

From: Kiriakos Georgiou <kg(dot)postgresql(at)olympiakos(dot)com>
To: rektide <rektide(at)voodoowarez(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: NOTIFY/LISTEN on server, asynchronous processing
Date: 2012-12-11 20:12:00
Message-ID: 4B80B542-6425-4C0A-A1D7-54908BF31CE1@olympiakos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If I'm understanding you correctly, you want a job queue.

This involves polling and retrieving jobs to work on them. The polling can be assisted by listen/notify so workers don't poll unnecessarily. The retrieving has to be done intelligently to avoid concurrency issues.

Kiriakos Georgiou
http://mockbites.com/about/email

On Dec 11, 2012, at 2:29 PM, rektide <rektide(at)voodoowarez(dot)com> wrote:

> Hi all, I'm writing seeking help for making asynchronous & decoupled processes run on a
> Postgres server.
>
> Here's my current hairbraned workingis:
> 1. Create an table "async_process" and attach a trigger after.
> 2. Establish a dblink to localhost.
> 3. dblink_send_query("update async_process set counter = counter + 1;") from other sprocs
> 3. Designated processing hanging off this "async_process" table now runs.
>
> All I'm doing is using a table, to create a trigger, that can be run asynchronously.
>
> There's at least two things gross about this strategy:
> 1. A "async_process" table exists only because I need a trigger that can be updated at will.
> 2. Having to dblink to oneself to run a query from inside the database asynchronously.
>
> Postgres has a capability for doing async work: NOTIFY/LISTEN. I'd like to verify first,
> LISTEN is only for clients, correct? There's no way I can define something resident on
> postgres itself that will LISTEN, that can be targetted by notifications?
>
> Does anyone have suggestions for decoupling work done on a server, for breaking up a task
> into multiple asychronous pieces? I believe I've described 1. a viable if ugly means of
> doing so, and 2. limitations in the primary asynchronous toolsuite of Postgres, and am
> looking for ways to make more progress.
>
> Regards,
> -rektide
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2012-12-11 20:13:58 PgAdmin question (maybe off topic)
Previous Message rektide 2012-12-11 19:29:38 NOTIFY/LISTEN on server, asynchronous processing