如何忽略 Weblogic 服务器中的卡住线程
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我采取了简单的方法(时间压力),在计时器到期时在 WorkManager 安排的工作中进行处理。
web.xml
weblogic.xml
I took the easy way out (time pressures) by doing the processing in work scheduled by a WorkManager when the timer expires.
web.xml
weblogic.xml
我还没有尝试过这个,但是在 weblogic.xml 中添加此条目应该可以工作
name
与 web.xml 中的res-ref-name
匹配我的服务器启动了计时器,好吧,我还没有测试你的客户端来看看卡住的线程消息是否被忽略
I havent tried this, but adding this entry in weblogic.xml should work
The
name
matchesres-ref-name
in web.xmlMy server started up with the Timer okay, I havent tested your client to see if the stuck thread messages are ignored