Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 07648CBE9BF for ; Thu, 15 Dec 2011 07:30:18 -0400 (AST) Received: from static-ip-217-118-26-141.inaddr.ip-pool.com ([217.118.26.141] helo=mail.softperience.eu) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rb9Vt-0007lv-9E for pgsql-jdbc@postgresql.org; Thu, 15 Dec 2011 11:30:19 +0000 Received: from mail.softperience.eu (loft2296 [217.118.26.141]) by mail.softperience.eu (Postfix) with ESMTPA id 71C9DC00035; Thu, 15 Dec 2011 12:29:58 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 15 Dec 2011 12:29:58 +0100 From: =?UTF-8?Q?Rados=C5=82aw_Smogura?= To: Craig Ringer Cc: David Fetter , Sylvain Mougenot , Subject: Re: Re: [SQL] JDBC Statement.setQueryTimeout : is there plan to implement =?UTF-8?Q?this=3F?= In-Reply-To: <4EE97B85.50909@ringerc.id.au> References: <4EE8AC41.2040505@ringerc.id.au> <20111214161349.GA31176@fetter.org> <4EE968FF.5010604@ringerc.id.au> <4EE97B85.50909@ringerc.id.au> Message-ID: X-Sender: rsmogura@softperience.eu User-Agent: Roundcube Webmail/0.5.4 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/60 X-Sequence-Number: 22514 Long, long time ago I've sent implementation with timers, you need to search archive If you need this. Regards, Radek On Thu, 15 Dec 2011 12:45:57 +0800, Craig Ringer wrote: >> I've popped a question up here: >> >> > > http://stackoverflow.com/questions/8514725/obtaining-a-java-util-timer-or-equivalent-in-a-javaee-friendly-way-that-works-on >> [1] >> >> to see if I can get some broader input on the issue of portable >> timers. > > ... and boy am I glad I did, thanks to Bauke Scholtz (BalusC) on SO. > > It looks like we can probably use a ScheduledThreadPoolExecutor > safely from within a Java EE container or servlet container, so long > as: > > - We never let EE application code that requires EE services - like > servlet code, EJBs, etc - run on its thread(s); and > > - We use a ServiceLoader in /META-INF/services to destroy it when > the > JDBC driver is unloaded, the war > the JDBC driver is bundled in is undeployed or the app server is > stopped; > > That should provide the JDBC driver with a suitable timer mechanism. > > Perhaps more excitingly, a generic ThreadPoolExecutor can be safely > used within an EE container the same way, potentially allowing the > JDBC driver to use threads for blocking I/O. That'd finally permit a > version of PgConnection.getNotifications() that can be safely invoked > without blocking when SSL is in use! > > A driver thread pool could also help permanently fix those > occasional > deadlocks that happen due to buffer management issues in the JDBC > driver. > > I'll try to find time to do some testing and see if I can make this > work or at least bash out a proof of concept. > > -- > Craig Ringer > > > Links: > ------ > [1] > > http://stackoverflow.com/questions/8514725/obtaining-a-java-util-timer-or-equivalent-in-a-javaee-friendly-way-that-works-on