2016-03-03 35 views
0

摘要:即使讀取器/處理器/寫入器成功,作業也會重新啓動/重試。即使在成功後,彈簧批次也會重複塊1的大小

我的步驟定義如下:

 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使用之前收集的數據進行具有基本身份驗證的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.tra[email protected]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: [email protected] 
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: [email protected] 
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. 

回答

0

你可以嘗試使用step listener,然後決定重複步驟或完成任務。檢查這answer

相關問題