-
1. Re: Method Timeout JBoss EAP 5.1
wdfink Feb 8, 2012 1:58 PM (in response to csariedd)I'm not very familiar with webservices, but
the transaction manager is only to ensure that the transaction timed out and can not commited after that.
The running method and webservice will not be interrupted!
-
2. Re: Method Timeout JBoss EAP 5.1
csariedd Feb 8, 2012 6:45 PM (in response to wdfink)Thanks for the reply. It seems that transaction time out is not what I'm looking for.
Does JBoss have the watchdog timeou mechanism somewhere?
What I'm trying to achieve is for the webservice operation to timeout internally by killing a thread that attempts to access an internal resource.
Otherwise I'll have to do it myself.
-
3. Re: Method Timeout JBoss EAP 5.1
wdfink Feb 9, 2012 1:55 AM (in response to csariedd)As the JEE spec is, you don't have to controll threads! Never start or stop threads or interfering in handling of it. Also you must not use any java.*io*.
What you might do is to use a asynchronous approach and wait for the future object some time, here you can cancel the operation. But it is the responsibillity of the container how to handle it, it might happen that the watched process will not be terminated imediately (or before finished).
Such Async processing is available for EJB3.1
-
4. Re: Method Timeout JBoss EAP 5.1
csariedd Feb 15, 2012 8:49 PM (in response to wdfink)Ouch, so that explains the odd behavior I'm getting when I attempt to cancel the future when a timeoutException occurs.
It seems to me the future might never gets canceled. (I have seen some cases where it did)
I even attempted to shutdown the executor that didn't help.
/** snippet from a class that handles request */ ExecutorService executor = Executors.newFixedThreadPool( 1 ); FutureTask< Status > future = (FutureTask) executor.submit( new Callable< Status >() { public Status call() { return action(); } } ); try { Status result = future.get( timeout, TimeUnit.MILLISECONDS ); } catch( TimeoutException te ) { future.cancel( true ); executor.shutdown(); try { executor.awaitTermination( 100, TimeUnit.NANOSECONDS ); /** I tried different combination of timeout it still didn't have an effect */ } catch (InterruptedException ignored) { executor.shutdownNow(); } } finally { return result; /** no matter what notify consumer of what's going on */ }
I noticed that action keeps on going, and the consumer recieves the correct timeout error! Not sure what's going on there.