2011-10-12 67 views
0

我在Weblogic應用服務器10.3.2上使用了下面的代碼。在timerExpired上執行的長時間運行的任務需要比服務器寬度爲600秒的StuckThreadMaxTime更長的時間。我不想修改此值,但只是忽略此特定處理線程的卡住線程超時。如何忽略Weblogic服務器中卡住的線程

我可以看到這是如何實現的使用中配置CommonJ WorkManager的從這個: http://download.oracle.com/docs/cd/E11035_01/wls100/config_wls/self_tuned.html#wp1069945

,然後通過添加以下內容在weblogic.xml文件中的工作管理系統代碼:

<ignore-stuck-threads>true</ignore-stuck-threads>

但是我怎麼能做一個Timer/TimerManager?

的web.xml

<resource-ref> 
<res-ref-name>tm/TestTimer</res-ref-name> 
<res-type>commonj.timers.TimerManager</res-type> 
<res-auth>Container</res-auth> 
<res-sharing-scope>Unshareable</res-sharing-scope> 
</resource-ref> 

TestTimer.java:

import commonj.timers.Timer; 
import commonj.timers.TimerListener; 
import commonj.timers.TimerManager; 

public class TestTimer implements TimerListener { 
    public void init() 
     TimerManager timerManager =  
      (TimerManager)initContext.lookup("java:comp/env/tm/TestTimer"); 
     timerManager.schedule(this, SCHEDULE_DELAY);        

    } 

    @Override 
    public void timerExpired(Timer timer) { 
     // perform long-running task  
    } 
} 

回答

1

我做一個WorkManager的計劃工作中的處理拿出最簡單的方式(時間壓力)當計時器到期時。

public MyClass implements TimerListener, Work 
    @Override 
    public void timerExpired(Timer timer) throws Exception {  
     WorkManager workManager = initContext.lookup("wm/myworkmanager"); 
     workManager.schedule(this);     
    } 

    @Override 
    public void run() { 
     doWork(); 
    } 
} 

的web.xml

<resource-ref> 
    <res-ref-name>wm/myworkmanager</res-ref-name> 
    <res-type>commonj.work.WorkManager</res-type> 
    <res-auth>Container</res-auth> 
    <res-sharing-scope>Unshareable</res-sharing-scope> 
</resource-ref> 

的weblogic.xml

<wls:work-manager> 
    <wls:name>wm/myworkmanager</wls:name>   
    <wls:ignore-stuck-threads>true</wls:ignore-stuck-threads> 
</wls:work-manager> 
0

我還沒有嘗試這樣做,但添加在weblogic.xml該條目應該工作

<work-manager> 
     <name>timer/TestTimer</name> 
     <ignore-stuck-threads>true</ignore-stuck-threads> 
    </work-manager> 

name比賽web.xml中的res-ref-name

我的服務器的定時器啓動還好,我還沒有測試客戶端,看是否阻塞線程消息被忽略

+0

嗨。我試過這個,似乎沒有工作,所以現在我正在調度WorkManager工作,當計時器到期時工作管理器配置設置爲忽略卡住的線程。 – rudolfv