pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Thiago Godoi <thiagogodoi10@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Send a command to postgres and close the program
Date: Sun, 12 Sep 2010 09:20:09 +0800
Message-ID: <4C8C2AC9.2080407@postnewspapers.com.au> (raw)
In-Reply-To: <AANLkTi=F1mBiWRyrSy9GLTKEwNpCD0UaXMbhaydSgaCm@mail.gmail.com>
References: <AANLkTimWKU2HgUWv=NYwZipZ0NjJ=h6ibzQrK8cgUQ0j@mail.gmail.com>
	<4C8828E9.8070809@postnewspapers.com.au>
	<AANLkTi=F1mBiWRyrSy9GLTKEwNpCD0UaXMbhaydSgaCm@mail.gmail.com>

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



view thread (4+ messages)

Message-ID: <4C8C2AC9.2080407@postnewspapers.com.au>
Permalink:  ../4C8C2AC9.2080407@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4C8C2AC9.2080407@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au, thiagogodoi10@gmail.com
  Subject: Re: Send a command to postgres and close the program
  In-Reply-To: <4C8C2AC9.2080407@postnewspapers.com.au>
  References: <AANLkTimWKU2HgUWv=NYwZipZ0NjJ=h6ibzQrK8cgUQ0j@mail.gmail.com> <4C8828E9.8070809@postnewspapers.com.au> <AANLkTi=F1mBiWRyrSy9GLTKEwNpCD0UaXMbhaydSgaCm@mail.gmail.com> <4C8C2AC9.2080407@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox