如何忽略 Weblogic 服务器中的卡住线程

发布于 2024-12-09 15:24:55 字数 1425 浏览 0 评论 0原文

我在 Weblogic 应用程序服务器 10.3.2 上运行了以下代码。在timerExpired 上执行的长时间运行任务花费的时间比服务器范围的StuckThreadMaxTime 600 秒长。我不想修改这个值,只是为了忽略这个特定处理线程的卡住线程超时。

我可以看到如何使用 commonj WorkManager 来完成此操作: http://download.oracle.com/docs/cd /E11035_01/wls100/config_wls/self_tuned.html#wp1069945

并且然后将以下内容添加到 weblogic.xml 文件中的 work-manager 标记中:

<忽略卡住线程>true

但是我到底如何为 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    
    }
}

I've got the below code working on Weblogic Application Server 10.3.2. The long running task executed on timerExpired takes longer than the server wide StuckThreadMaxTime of 600 seconds. I do not want to modify this value, but just to ignore the stuck thread timeout for this particular thread of processing.

I can see how this can be accomplished using a commonj WorkManager from this:
http://download.oracle.com/docs/cd/E11035_01/wls100/config_wls/self_tuned.html#wp1069945

And then by adding the following to the work-manager tag in the weblogic.xml file:

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

But how on earth do I do the same for a 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    
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

メ斷腸人バ 2024-12-16 15:24:55

我采取了简单的方法(时间压力),在计时器到期时在 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>

I took the easy way out (time pressures) by doing the processing in work scheduled by a WorkManager when the timer expires.

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>
酷到爆炸 2024-12-16 15:24:55

我还没有尝试过这个,但是在 weblogic.xml 中添加此条目应该可以工作

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

name 与 web.xml 中的 res-ref-name 匹配

我的服务器启动了计时器,好吧,我还没有测试你的客户端来看看卡住的线程消息是否被忽略

I havent tried this, but adding this entry in weblogic.xml should work

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

The name matches res-ref-name in web.xml

My server started up with the Timer okay, I havent tested your client to see if the stuck thread messages are ignored

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文