我面临着weblogic中一些参数的奇怪行为。我有一个J2EE批处理,它在weblogic中执行超过10分钟,这会导致一个异常,如
com.ibm.jbatch.container.exception.BatchContainerRuntimeException:
java.lang.InterruptedException
经过一些调查后,我发现属性MaxStuckThreadTime设置为600秒(默认值),属性StuckThreadCount设置为25 (过去为0,没有任何问题)。如果我理解得很好,这意味着服务器应该失败当且仅当至少有25个线程正忙着,因为超过600秒。但在服务器上,最多有10个线程同时运行。我对开发环境进行了一些测试,一旦我有一个线程卡住了( 10分钟内忙了,就启动了相互关联的异常),这是预期的行为吗?
我没有权利在生产中修改这些价值。所以,任何想法都是欢迎通过这种错误的。
在文档中,我发现:
StuckThreadCount = The number of stuck threads after which the server is transitioned into FAILED state.
MaxStuckThreadTime = Sets the value of the MaxStuckThreadTime attribute.因此,在我的观点中,插入的超出,应该出现只有当两个条件是字段,但我有一个印象,只有一个卡住线程是足够插入批处理。如果我说MaxStuckThreadTime只在StuckThreadCount与0不同的情况下才被考虑,那么我会纠正吗?
提前感谢您的帮助
编辑:
我试图在这里实施这项建议,但到目前为止,都没有成功。因此,在我的weblogic-ejb-jar.xml中,我添加了以下代码:
<work-manager>
<name>BatchWorkManager</name>
<ignore-stuck-threads>true</ignore-stuck-threads>
</work-manager>
<managed-executor-service>
<name>batch-job-executor</name>
<dispatch-policy>BatchWorkManager</dispatch-policy>
<long-running-priority>10</long-running-priority>
</managed-executor-service>在我的批次中,我加入了
@Resource(name = "BatchWorkManager")
WorkManager myMW;像这样呼叫我的批次
@重写公共字符串进程()引发异常{
myWM.schedule(new MyWork("MyBatchName"));
return BatchStatus.COMPLETED.toString();
}几分钟后(在MaxStuckThreadTime参数中定义),作业处于状态失败。如果调试代码,将看到工作管理器的值:
stuckThreadActions = null name =“没有卡住的线程操作!”stuckThreads = {BitSet@36226} "{}“
看来,工作管理器是正确的设置(没有卡住线程操作!是我想要的)。所以,我还是不明白,为什么这批货失败了.欢迎任何帮助。
作为参考,我收到的statcktrace:
### < CEST> ExecuteThread:'0‘用于队列:'weblogic.kernel.Default (自调优)’> <> <1650537600793> <严重性-值: 16分区-id:0><捕获异常执行步骤: com.ibm.jbatch.container.exception.BatchContainerRuntimeException: java.lang.InterruptedException at com.ibm.jbatch.container.impl.PartitionedStepControllerImpl.executeAndWaitForCompletion(PartitionedStepControllerImpl.java:407) at com.ibm.jbatch.container.impl.PartitionedStepControllerImpl.invokeCoreStep(PartitionedStepControllerImpl.java:297) at com.ibm.jbatch.container.impl.BaseStepControllerImpl.execute(BaseStepControllerImpl.java:144) at com.ibm.jbatch.container.impl.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:112) at com.ibm.jbatch.container.impl.JobThreadRootControllerImpl.originateExecutionOnThread(JobThreadRootControllerImpl.java:110) at com.ibm.jbatch.container.util.BatchWorkUnit.run(BatchWorkUnit.java:80) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at weblogic.work.concurrent.weblogic.work.concurrent.future.AbstractFutureImpl.runTask(AbstractFutureImpl.java:391),weblogic.work.concurrent.future.AbstractFutureImpl.doRun(AbstractFutureImpl.java:436),weblogic.work.concurrent.future.ManagedFutureImpl.run(ManagedFutureImpl.java:28),weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348),weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333),weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54),weblogic.work.PartitionUtility。weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406) at weblogic.work.ExecuteThread.run(ExecuteThread.java:346) com : java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2048) at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) at com.ibm.jbatch.container.impl.PartitionedStepControllerImpl.executeAndWaitForCompletion(PartitionedStepControllerImpl.java:402) .再来17
发布于 2022-04-08 23:25:16
您可以为运行批处理作业配置一个新的工作管理器,并将卡住的线程配置为被忽略,或者将批处理作业作为一个长时间运行的请求启动。
工作管理器可以通过weblogic控制台进行全局配置,也可以在本地为每个已部署的应用程序配置。要在应用程序中定义工作管理器,可以在随部署打包的weblogic.xml (或等效的ear文件)中配置它。例如,我在我的weblogic.xml文件中定义了一个忽略卡住线程的工作管理器.
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
...
<work-manager>
<name>batch-job-wm</name>
<max-threads-constraint>
<name>batch-job-max-threads</name>
<count>10</count>
</max-threads-constraint>
<ignore-stuck-threads>true</ignore-stuck-threads>
</work-manager>
<managed-executor-service>
<name>batch-job-executor</name>
<dispatch-policy>batch-job-wm</dispatch-policy>
<long-running-priority>10</long-running-priority>
<max-concurrent-long-running-requests>10</max-concurrent-long-running-requests>
</managed-executor-service>
<resource-env-description>
<resource-env-ref-name>concurrent/batch-job-executor</resource-env-ref-name>
<resource-link>batch-job-executor</resource-link>
</resource-env-description>
...
</weblogic-web-app>我指的是我的web.xml中的托管执行者服务.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
...
<resource-env-ref>
<resource-env-ref-name>concurrent/batch-job-executor</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>
</web-app>在我的web应用程序中,我可以访问任务执行器,如下所示.
@Configuration
public class ResourceConfig {
@Bean
public TaskExecutor batchTaskExecutor() {
DefaultManagedTaskExecutor taskExecutor = new DefaultManagedTaskExecutor();
taskExecutor.setJndiName("java:comp/env/concurrent/batch-job-executor");
return taskExecutor;
}
}当使用该工作管理器启动批处理作业时,任何阻塞的线程都会被weblogic忽略,即使对于长期运行的任务,服务器也显示为健康的。
对此的一个改进是将批处理作业作为long running task启动。我认为这将导致weblogic为任务创建一个新线程,而不是从工作管理器线程池中获取一个线程。而且,weblogic不会将分配给长期运行的任务的线程视为卡住。
要启动长期运行的任务,需要在启动的LONGRUNNING_HINT中将ManagedTask设置为true。有关更多细节,请参见以下内容..。
https://docs.oracle.com/javaee/7/api/javax/enterprise/concurrent/ManagedTask.html#LONGRUNNING_HINT
https://docs.oracle.com/javaee/7/api/javax/enterprise/concurrent/ManagedExecutorService.html
https://stackoverflow.com/questions/71797780
复制相似问题