2017-12-19 2 views
0

は、実際に私はいくつかのステップと次のように2つのタスクレットで仕事をjave。ロールバック春のバッチジョブ

@Configuration 
@Import({BatchItemConfiguration.class, BatchCriticalComponentConfiguration.class}) 
public class BatchConfiguration { 

@Autowired 
private JobBuilderFactory jobBuilderFactory; 

@Autowired 
private Step stepCriticalComponent; 

@Autowired 
private Step stepItem; 

@Autowired 
private Step deleteAllItemStep; 

@Autowired 
private Step deleteAllCriticalComponentStep; 

@Bean 
public Job importJob(JobCompletionNotificationListener listener) { 
    return jobBuilderFactory.get("importJob") 
      .incrementer(new RunIdIncrementer()) 
      .listener(listener) 
      .start(deleteAllCriticalComponentStep) 
      .next(deleteAllItemStep) 
      .next(stepItem).next(stepCriticalComponent) 
      .build(); 
} 

}

ステップ(stepItem又はstepCriticalComponent)が失敗した場合、実際には、タスクレットによって削除されたデータがなくなっていると私はそれを回復することができません。 特定のステップ/タスクレットの前に、ジョブ全体またはロールバックをロールバックする方法はありますか?

答えて

0

Springバッチ内のジョブまたはステップ全体のロールバックという概念はありません。ただし、リスナー(JobExecutionListenerまたはStepExecutionListener)を使用して、手動でロールバックを実行するための補正ロジックを実行できます。

関連する問題