[jboss-jira] [JBoss JIRA] (WFLY-12329) ManagedScheduledExecutorService should be only available after server is ready

nimo stephan (Jira) issues at jboss.org
Mon Jul 29 19:17:00 EDT 2019


    [ https://issues.jboss.org/browse/WFLY-12329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13764490#comment-13764490 ] 

nimo stephan commented on WFLY-12329:
-------------------------------------

> can you please clarify what behaviour you expected?

"ManagedScheduledExecutorService" should only activated *after server is fully initiated and NOT in suspend mode*. 

_I does not make sense to start the ManagedScheduledExecutorService before.  For example, the ejb timer service will only fire if server is ready (fully initiated and not in suspend mode). The same should go for "ManagedScheduledExecutorService"._


> creating, starting, stopping or destroying executors (you are actually forbidden to use API lifecycle related methods)

Thanks for the hint. 

*One question:*

So why can I access something like 
{code:java}
executor.shutdown();
{code}
 or 
{code:java}
executor.shutdownNow(); 
{code}
from the 
{code:java}
ManagedScheduledExecutorService
{code}
 when all these methods are prohibited in JEE and therefore also throw exceptions?





> ManagedScheduledExecutorService should be only available after server is ready
> ------------------------------------------------------------------------------
>
>                 Key: WFLY-12329
>                 URL: https://issues.jboss.org/browse/WFLY-12329
>             Project: WildFly
>          Issue Type: Bug
>          Components: Concurrency Utilities
>    Affects Versions: 17.0.1.Final
>            Reporter: nimo stephan
>            Assignee: Eduardo Martins
>            Priority: Major
>
> I use a *ManagedScheduledExecutorService* to execute tasks periodically:
> {code:java}
> @Startup
> @Singleton
> public class TaskScheduler {
>     @Resource
>     ManagedScheduledExecutorService executorService;
>     @PostConstruct
>     public void init() {
>         executorService.scheduleAtFixedRate(this::task, 0, 5, TimeUnit.SECONDS);
>     }
>     public void task() {
>         System.out.println("long running task:" + LocalTime.now());
>     }
> }
> {code}
> Wildfly throws a few exceptions as long as server is not fully initiated and in "suspend"-mode:
> {code:java}
> 12:44:12,715 ERROR [org.jboss.as.ee] (EE-ManagedScheduledExecutorService-default-Thread-3) WFLYEE0110: Failed to run scheduled task: java.lang.IllegalStateException: WFLYEE0111: Cannot run scheduled task my.Task$$Lambda$1041/0x000000080240a040 at 5ee966ec as container is suspended
> 	at org.jboss.as.ee at 17.0.1.Final//org.jboss.as.ee.concurrent.ControlPointUtils$ControlledScheduledRunnable.run(ControlPointUtils.java:164)
> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> 	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
> 	at org.glassfish.javax.enterprise.concurrent//org.glassfish.enterprise.concurrent.internal.ManagedScheduledThreadPoolExecutor$ManagedScheduledFutureTask.access$201(ManagedScheduledThreadPoolExecutor.java:383)
> 	at org.glassfish.javax.enterprise.concurrent//org.glassfish.enterprise.concurrent.internal.ManagedScheduledThreadPoolExecutor$ManagedScheduledFutureTask.run(ManagedScheduledThreadPoolExecutor.java:534)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> 	at java.base/java.lang.Thread.run(Thread.java:835)
> 	at org.glassfish.javax.enterprise.concurrent//org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl$ManagedThread.run(ManagedThreadFactoryImpl.java:250)
> {code}
> I use _ManagedScheduledExecutorService_ instead of _ScheduledExecutorService_ in JEE because, *ManagedScheduledExecutorService* should be managed by JEE. Hence, the server should also manage and guarantee not to fire the executorService until the server is ready (and EJBs are available).



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list