簡體   English   中英

在Java EE 7應用程序中使用ThreadPoolExecutor進行Drools會導致重新部署問題

[英]Drools using ThreadPoolExecutor in Java EE 7 application causes problems on redeploy

我們在Weblogic 12.2.1上的JavaEE 7應用程序中使用Drools 6.3.0Final。 當我們的應用程序最初部署時,我們看到8個名為“drools-worker-X”的線程,其中X的范圍是1到8(在帶有HT的4核CPU上)。 現在,當我們重新部署應用程序時,8個線程保持在“Park”狀態,並創建8個新線程(再次編號從1到8)。 每次重新部署都會繼續。

我們發現包org.drools.core.concurrent中的類ExecutorProviderImpl創建了一個新的ThreadPoolExecutor,其corePoolSize和maxPoolSize都設置為CPU核心數,Timeout設置為60s。 一旦我們重新部署了一定次數,JVM就會變慢並且我們的應用程序不再正常運行。

當我們的應用程序關閉時,有沒有辦法正確關閉這些工作線程?

您可以實現一個Startup-EJB,它在@PreDestroy -annotated方法中關閉ExecutorService 我只是在我們自己的項目中測試它,它看起來像一個魅力。

import java.util.concurrent.ExecutorService;
import org.kie.internal.concurrent.ExecutorProviderFactory;
...

@Startup
@Singleton
public class PlausiServiceLifecycleManager {

    /**
     * Shuts down Drools' internal ExecutorService, so that its threads can terminate.
     */
    @PreDestroy
    public void shutdown() {
        ExecutorService executor = (ExecutorService) ExecutorProviderFactory.getExecutorProvider().getExecutor();
        executor.shutdown();
    }


}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM