From: | Kiriakos Georgiou <kg(dot)postgresql(at)olympiakos(dot)com> |
---|---|
To: | bret_stern(at)machinemanagement(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Regarding NOTIFY |
Date: | 2012-03-09 23:48:21 |
Message-ID: | 0B9886CF-2A92-429A-A085-731732A591A2@olympiakos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yes, can do. Just have an insert trigger on the jobs table that notifies the monitor, something like:
CREATE OR REPLACE FUNCTION notify_monitor()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $$
BEGIN
NOTIFY monitor;
RETURN NULL;
END
$$
CREATE TRIGGER jobs_trigger
AFTER INSERT
ON jobs
FOR EACH STATEMENT
EXECUTE PROCEDURE notify_monitor();
Then all the monitor has to do is wait for notifications. For C, see http://www.postgresql.org/docs/9.1/static/libpq-notify.html
ruby-pg (the official ruby api to postgresql) has wait_for_notify(), which pretty much implements what the postgresql docs suggest.
Kiriakos
http://www.mockbites.com
On Mar 9, 2012, at 11:53 AM, Bret Stern wrote:
> We have a concrete batching application composed of two parts.
> 1. The Monitor.
> The Monitor cycles every 60 seconds, and looks into a Postgresql table
> for jobs to run. Primarily these jobs update Postgresql tables with
> data from external applications.
>
> 2. The Client.
> The client schedules orders etc.
>
> When a new product or customer is added to the Accounting or Batching
> Controller (both external applications; and databases) the Client user
> clicks a button and adds a job to run on the Monitor.
>
> Is it possible use the NOTIFY event to serve more like an interrupt,
> and trigger the Monitor to run immediately.
>
> Can it be used with VB?
> or
> Should I use LibPQ?
>
> Any suggestions welcome.
>
>
> If this is the wrong list for these questions, let me know?
>
> Bret Stern
>
>
>
>
>
>
>
> --
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2012-03-10 03:11:03 | Re: advice on Replication for a Specific Scenario |
Previous Message | Chris Travers | 2012-03-09 23:35:40 | Re: Regarding NOTIFY |