0

我尝试在执行 Java-EE 批处理执行时获取正在运行的执行。通过 BatchRuntime.getJobOperator().start(JOBNAME,parameters) 首次执行时,一切正常:

BatchRuntime.getJobOperator().getRunningExecutions(JOBNAME)提供正确的执行并 BatchRuntime.getJobOperator().getJobInstanceCount(JOBNAME)导致“1”。

批处理执行完成(使用 BatchStatus.COMPLETED.toString())。在所有连续运行期间,会发生以下情况:

BatchRuntime.getJobOperator().getJobInstanceCount(JOBNAME)-result 增加,所以它变成 2, 3, ....

BatchRuntime.getJobOperator().getRunningExecutions(JOBNAME)抛出:

javax.batch.operations.NoSuchJobException: Job Name TestBatchProcessing not found
at org.apache.batchee.container.impl.JobOperatorImpl.getRunningExecutions(JobOperatorImpl.java:314)
at ....BusinessLogic.process(BusinessLogic.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.batchee.container.proxy.BatchProxyInvocationHandler.invoke(BatchProxyInvocationHandler.java:55)
at com.sun.proxy.$Proxy125.process(Unknown Source)
at org.apache.batchee.container.impl.controller.batchlet.BatchletStepController.invokeBatchlet(BatchletStepController.java:58)
at org.apache.batchee.container.impl.controller.batchlet.BatchletStepController.invokeCoreStep(BatchletStepController.java:86)
at org.apache.batchee.container.impl.controller.BaseStepController.execute(BaseStepController.java:152)
at org.apache.batchee.container.impl.controller.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:106)
at org.apache.batchee.container.impl.controller.FlowController.execute(FlowController.java:58)
at org.apache.batchee.container.impl.controller.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:106)
at org.apache.batchee.container.impl.controller.JobThreadRootController.originateExecutionOnThread(JobThreadRootController.java:110)
at org.apache.batchee.container.util.BatchWorkUnit.run(BatchWorkUnit.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.batchee.container.util.ClassLoaderAwareHandler.invoke(ClassLoaderAwareHandler.java:39)
at com.sun.proxy.$Proxy123.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

以下是 getRunningExecutions 应该找到的正在运行的 Jobexecution 的属性值(但没有):

jobProperties: {createTime=2016-08-18 12:45:05.559}
batchStatus: STARTED
exitStatus: null
jobName: TestBatchProcessing
instanceId: 1
executionId: 1

有谁知道这个例外的原因?是否有必要清理作业实例?如果需要,我可以附加具体的代码片段。

预先感谢您的回答。

编辑:getJobInstanceCount 不会一直为 2。每次新作业开始时它都会增加一。

4

0 回答 0