Re: Send a command to postgres and close the program - Mailing list pgsql-jdbc

From Craig Ringer
Subject Re: Send a command to postgres and close the program
Date
Msg-id 4C8C2AC9.2080407@postnewspapers.com.au
Whole thread Raw
In response to Re: Send a command to postgres and close the program  (Thiago Godoi <thiagogodoi10@gmail.com>)
List pgsql-jdbc
On 09/11/2010 11:04 AM, Thiago Godoi wrote:
> The long-running work will be a command without data transfer to the
> server , that needs to continue processing the command after the client
> close the conection/program .
>
> This function of send a command to the server is for apply correction
> patchs in the database.

OK, so you almost certainly want to do this server-side. Create a queue
table, and have your client insert the required information into the
queue table. Create a trigger on the queue table that fires a NOTIFY
when something is inserted into it. Write a server-side script/program
that maintains a connection to the database and LISTENs to the message
your queue table NOTIFY will send.  When the server side program
receives a NOTIFY, it should read the queue table and start the required
long-running processing for each entry it finds.

Since you're using Java on the client side you'll probably want to write
a simple command-line J2SE app for the server-side part. All it has to
do is eastablish a JDBC connection, obtain the PGConnection from it, and
loop checking  for notifications. Launch it as a daemon/service on your
server and you're set.

--
Craig Ringer

pgsql-jdbc by date:

Previous
From: Petr Prikryl
Date:
Subject: Re: Eager fetch of Array in one tcp connection
Next
From: Kim Bisgaard
Date:
Subject: Synchronisation problems in COPY IN