即使成功后,Spring Batch也会重复步骤大小为1

时间:2016-03-03 20:10:16

标签: spring spring-boot spring-batch spring-jms spring-retry

摘要:即使读取器/处理器/写入器成功,作业也会重新启动/重试。

我的步骤定义如下:

        return stepBuilder.get("job.transaction-export.step1")
            // .startLimit(stepStartLimit)
            .<AfxEntity, AfxEntity> chunk(chunkSize)
            .reader(reader)
            .processor(processor)
            .writer(writer)
            // .faultTolerant()
            // .backOffPolicy(exponentialRandomBackOffPolicy)
            // .retry(HttpServerErrorException.class)
            // .retry(UnknownHttpStatusCodeException.class)
            // .retry(ResourceAccessException.class)
            // .noRetry(HttpClientErrorException.class)
            .build();

在某些时候,我希望某些HTTP错误触发重试,但此时,所有代码都被注释掉了。我只有简单的类实现Item *接口,块大小为1。

我没有做任何我能告诉的事情,导致重复政策不止一次。

我的应用程序是一个Spring Boot应用程序,它有几个JMS侦听器。当侦听器收到消息时,它会使用消息内容调度相应的Job。

这项工作是出口。 JMS消息提供要导出的记录的ID。 ItemReader(用@StepScope注释)将记录拉入Map。 ItemProcessor将其他数据添加到Map。 ItemWriter使用Basic Auth执行带有先前收集的数据的HTTP POST。

测试类在单独的进程中注册REST侦听器并发布JMS消息。当REST方法获取它退出的消息时。这意味着成功。 (测试需要加强。)

现在正在发生的事情是,尽管成功(无异常/错误,auth传递,数据双向交换)REST事务,Batch框架重复该步骤。由于测试类在响应REST请求后退出,因此新POST失败。我让它运行一次,然后重复超过120次。

问题:如果成功,我如何防止重试/重复机制被触发?

日志:

2016-03-03 14:19:44.952 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.TransactionMQListener          : Received message ActiveMQTextMessage {message found in here} with listener com.abc.afx.exporter.transaction.TransactionMQListener$$EnhancerBySpringCGLIB$$11c2ee83@480f78d0.
2016-03-03 14:19:44.955 DEBUG 26954 --- [enerContainer-1] c.a.a.e.t.TransactionMQListener          : jobParameters = {job parameters here}
2016-03-03 14:19:44.956 DEBUG 26954 --- [enerContainer-1] BatchConfiguration$ReferenceTargetSource : Initializing lazy target object
2016-03-03 14:19:45.847  INFO 26954 --- [enerContainer-1] o.s.b.c.l.support.SimpleJobLauncher      : Job: [SimpleJob: [name=job.transaction-export]] launched with the following parameters: [{job parameters here, launchTime=1457032784898}]
2016-03-03 14:19:45.848 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.job.AbstractJob           : Job execution starting: JobExecution: id=371, version=0, startTime=null, endTime=null, lastUpdated=Thu Mar 03 14:19:45 EST 2016, status=STARTING, exitStatus=exitCode=UNKNOWN;exitDescription=, job=[JobInstance: id=370, version=0, Job=[job.transaction-export]], jobParameters=[{job parameters here, launchTime=1457032784898}]
2016-03-03 14:19:45.850 DEBUG 26954 --- [enerContainer-1] BatchConfiguration$ReferenceTargetSource : Initializing lazy target object

// step starts here
2016-03-03 14:19:46.658  INFO 26954 --- [enerContainer-1] o.s.batch.core.job.SimpleStepHandler     : Executing step: [job.transaction-export.step1]
2016-03-03 14:19:46.658 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.AbstractStep         : Executing: id=372
2016-03-03 14:19:46.810 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Creating object in scope=step, name=scopedTarget.reader
2016-03-03 14:19:46.817 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Registered destruction callback in scope=step, name=scopedTarget.reader
2016-03-03 14:19:46.817 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Creating object in scope=step, name=scopedTarget.reader.transaction
2016-03-03 14:19:46.819 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Registered destruction callback in scope=step, name=scopedTarget.reader.transaction
2016-03-03 14:19:46.947 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Starting repeat context.
2016-03-03 14:19:46.947 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat operation about to start at count=1
2016-03-03 14:19:46.948 DEBUG 26954 --- [enerContainer-1] o.s.b.c.s.c.StepContextRepeatCallback    : Preparing chunk execution for StepContext: org.springframework.batch.core.scope.context.StepContext@d9db406
2016-03-03 14:19:46.948 DEBUG 26954 --- [enerContainer-1] o.s.b.c.s.c.StepContextRepeatCallback    : Chunk execution starting: queue size=0
2016-03-03 14:19:46.950 DEBUG 26954 --- [enerContainer-1] BatchConfiguration$ReferenceTargetSource : Initializing lazy target object
2016-03-03 14:19:46.981 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Starting repeat context.
2016-03-03 14:19:46.981 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat operation about to start at count=1
2016-03-03 14:19:46.992 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.job.reader.TransactionReader   : In TransactionReader.read
2016-03-03 14:19:47.034 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.job.reader.TransactionReader   : paymentTransaction = {map data in here}
2016-03-03 14:19:47.034 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat is complete according to policy and result value.
2016-03-03 14:19:47.035 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.p.TransactionProcessor       : In TransactionProcessor.process with paymentTransaction {map data in here}
2016-03-03 14:19:47.038 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.p.TransactionProcessor       : returnAfxEntity = {map data in here}
2016-03-03 14:19:47.038 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Creating object in scope=step, name=scopedTarget.writer.transaction-xyz
2016-03-03 14:19:47.041 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.scope.StepScope           : Registered destruction callback in scope=step, name=scopedTarget.writer.transaction-xyz
2016-03-03 14:19:47.068 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.w.v.TransactionXyzWriter     : POSTing to http://localhost:19999/transactionExportJob
2016-03-03 14:19:47.307 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.w.v.TransactionXyzWriter     : jsonObject = {"success":"true"}
2016-03-03 14:19:47.308 DEBUG 26954 --- [enerContainer-1] o.s.b.c.step.item.ChunkOrientedTasklet   : Inputs not busy, ended: false
2016-03-03 14:19:47.308 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.tasklet.TaskletStep  : Applying contribution: [StepContribution: read=1, written=1, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
2016-03-03 14:19:47.341 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.tasklet.TaskletStep  : Saving step execution before commit: StepExecution: id=372, version=1, name=job.transaction-export.step1, status=STARTED, exitStatus=EXECUTING, readCount=1, filterCount=0, writeCount=1 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=0, exitDescription=

// repeat starts here
2016-03-03 14:19:47.466 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat operation about to start at count=2
2016-03-03 14:19:47.466 DEBUG 26954 --- [enerContainer-1] o.s.b.c.s.c.StepContextRepeatCallback    : Preparing chunk execution for StepContext: org.springframework.batch.core.scope.context.StepContext@d9db406
2016-03-03 14:19:47.466 DEBUG 26954 --- [enerContainer-1] o.s.b.c.s.c.StepContextRepeatCallback    : Chunk execution starting: queue size=0
2016-03-03 14:19:47.496 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Starting repeat context.
2016-03-03 14:19:47.497 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat operation about to start at count=1
2016-03-03 14:19:47.497 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.job.reader.TransactionReader   : In TransactionReader.read
2016-03-03 14:19:47.534 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.job.reader.TransactionReader   : paymentTransaction = {map details here}
2016-03-03 14:19:47.534 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Repeat is complete according to policy and result value.
2016-03-03 14:19:47.534 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.p.TransactionProcessor       : In TransactionProcessor.process with paymentTransaction {map details here}
2016-03-03 14:19:47.534 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.p.TransactionProcessor       : returnAfxEntity = {map details here}
2016-03-03 14:19:47.542 TRACE 26954 --- [enerContainer-1] c.a.a.e.t.j.w.v.TransactionXyzWriter     : POSTing to http://localhost:19999/transactionExportJob
2016-03-03 14:19:47.546 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.tasklet.TaskletStep  : Applying contribution: [StepContribution: read=1, written=0, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
2016-03-03 14:19:47.546 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.tasklet.TaskletStep  : Rollback for RuntimeException: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
2016-03-03 14:19:47.601 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Handling exception: org.springframework.web.client.ResourceAccessException, caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
2016-03-03 14:19:47.601 DEBUG 26954 --- [enerContainer-1] o.s.batch.repeat.support.RepeatTemplate  : Handling fatal exception explicitly (rethrowing first of 1): org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
2016-03-03 14:19:47.608 ERROR 26954 --- [enerContainer-1] o.s.batch.core.step.AbstractStep         : Encountered an error executing step job.transaction-export.step1 in job job.transaction-export

org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter.write(TransactionXyzWriter.java:89) ~[classes/:na]
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$FastClassBySpringCGLIB$$7020a21.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$EnhancerBySpringCGLIB$$3eabc04e.write(<generated>) ~[classes/:na]
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:175) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:151) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:274) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:199) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374) ~[spring-batch-infrastructure-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144) ~[spring-batch-infrastructure-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200) ~[spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:392) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) [spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128) [spring-batch-core-3.0.6.RELEASE.jar:3.0.6.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
    ...
Caused by: java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:792) ~[na:1.8.0_51]
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647) ~[na:1.8.0_51]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535) ~[na:1.8.0_51]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440) ~[na:1.8.0_51]
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) ~[na:1.8.0_51]
    at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:48) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.http.client.AbstractClientHttpResponse.getStatusCode(AbstractClientHttpResponse.java:33) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.DefaultResponseErrorHandler.getHttpStatusCode(DefaultResponseErrorHandler.java:56) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:50) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:629) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    ... 63 common frames omitted

2016-03-03 14:19:47.758 DEBUG 26954 --- [enerContainer-1] o.s.b.c.r.dao.JdbcStepExecutionDao       : Truncating long message before update of StepExecution, original message is: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter.write(TransactionXyzWriter.java:89)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$FastClassBySpringCGLIB$$7020a21.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$EnhancerBySpringCGLIB$$3eabc04e.write(<generated>)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:175)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:151)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:274)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:199)
    at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
    at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
    at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
    at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
    at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
    at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:392)
    at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ...
Caused by: java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:792)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    at org.springframework.http.client.SimpleClientHttpResponse.getRawStatusCode(SimpleClientHttpResponse.java:48)
    at org.springframework.http.client.AbstractClientHttpResponse.getStatusCode(AbstractClientHttpResponse.java:33)
    at org.springframework.web.client.DefaultResponseErrorHandler.getHttpStatusCode(DefaultResponseErrorHandler.java:56)
    at org.springframework.web.client.DefaultResponseErrorHandler.hasError(DefaultResponseErrorHandler.java:50)
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:629)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597)
    ... 63 more

2016-03-03 14:19:47.892 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.step.AbstractStep         : Step execution complete: StepExecution: id=372, version=3, name=job.transaction-export.step1, status=FAILED, exitStatus=FAILED, readCount=2, filterCount=0, writeCount=1 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=1
2016-03-03 14:19:48.017 DEBUG 26954 --- [enerContainer-1] o.s.batch.core.job.AbstractJob           : Upgrading JobExecution status: StepExecution: id=372, version=3, name=job.transaction-export.step1, status=FAILED, exitStatus=FAILED, readCount=2, filterCount=0, writeCount=1 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=1, rollbackCount=1, exitDescription=org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://localhost:19999/transactionExportJob": Unexpected end of file from server; nested exception is java.net.SocketException: Unexpected end of file from server
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:607)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:475)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter.write(TransactionXyzWriter.java:89)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$FastClassBySpringCGLIB$$7020a21.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
    at com.abc.afx.exporter.transaction.job.writer.xyz.TransactionXyzWriter$$EnhancerBySpringCGLIB$$3eabc04e.write(<generated>)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:175)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:151)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:274)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:199)
    at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
    at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
    at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
    at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
    at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
    at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:392)
    at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ...
Caused by: java.net.SocketException: Unexpected end of file from server
    ... 74 more

...

, job=[JobInstance: id=370, version=0, Job=[job.transaction-export]], jobParameters=[{job parameters here, launchTime=1457032784898}]
2016-03-03 14:19:48.018 TRACE 26954 --- [enerContainer-1] .p.j.PatientScheduleJobExecutionListener : Job {job parameters here, launchTime=1457032784898} has completed.

1 个答案:

答案 0 :(得分:0)

您可以尝试使用step listener,然后决定重复一步或完成工作。请检查此answer