From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Thiago Godoi <thiagogodoi10(at)gmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Send a command to postgres and close the program |
Date: | 2010-09-12 01:20:09 |
Message-ID: | 4C8C2AC9.2080407@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Kim Bisgaard | 2010-09-13 12:13:24 | Synchronisation problems in COPY IN |
Previous Message | Petr Prikryl | 2010-09-11 21:24:43 | Re: Eager fetch of Array in one tcp connection |