Yeniden Başlatma ve Hata Yönetimi
Toplu işlerindeki hatalardan kurtulun.
Yeniden Başlatma ve Hata Yönetimi, CoddyKit'te ücretsiz bir Spring Boot 4 Microservices & REST APIs dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Spring Boot 4 Microservices & REST APIs öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Failures are inevitable
Long batch jobs hit bad rows, transient network errors, and crashes. Spring Batch provides skip, retry and restartability so a job can survive and resume.
Restartability basics
Because the JobRepository records each step execution, a failed job can be restarted and it resumes from where it stopped, not from the beginning. The same JobParameters must be used.
Re-launching a failed job
Relaunch with the same parameters and Spring Batch detects the prior failed execution and continues it. Completed steps are skipped.
JobParameters params = new JobParametersBuilder()
.addString("runDate", "2026-05-30")
.toJobParameters();
// running again with SAME params resumes the failed instance
jobLauncher.run(importJob, params);Skipping bad items
Use a fault-tolerant step to skip records that throw a given exception, up to a limit, instead of failing the whole job.
return new StepBuilder("step1", repo)
.<Person, Person>chunk(10, tx)
.reader(reader()).processor(proc()).writer(writer())
.faultTolerant()
.skip(ParseException.class)
.skipLimit(20)
.build();Skip limit
The skipLimit caps how many skips are tolerated. Once exceeded, the step fails. This prevents a job from silently ignoring a flood of bad data.
Retrying transient errors
For temporary failures (a deadlock, a brief network blip) use retry. The item operation is retried up to a limit before being skipped or failing.
return new StepBuilder("step1", repo)
.<Person, Person>chunk(10, tx)
.reader(reader()).processor(proc()).writer(writer())
.faultTolerant()
.retry(DeadlockLoserDataAccessException.class)
.retryLimit(3)
.build();Combining skip and retry
You can chain both: retry transient exceptions a few times, and skip persistent ones. Order matters - retry first, then skip if retries are exhausted.
.faultTolerant()
.retry(TransientException.class).retryLimit(3)
.skip(InvalidDataException.class).skipLimit(50)SkipListener and RetryListener
Listeners let you observe and log what was skipped or retried, which is essential for auditing batch runs.
public class LogSkipListener implements SkipListener<Person, Person> {
@Override
public void onSkipInProcess(Person item, Throwable t) {
log.warn("Skipped {} due to {}", item, t.getMessage());
}
}Idempotency matters
On restart, already-committed chunks are not re-read, but your writes should still be idempotent where possible (use upserts or natural keys) so a partial run does not create duplicates.
No-rollback exceptions
Sometimes an exception should not roll back the chunk. Declare it with noRollback so processing continues without discarding the transaction.
.faultTolerant()
.noRollback(NonCriticalException.class)Preventing accidental reruns
A completed JobInstance cannot be re-run with the same parameters - Spring throws JobInstanceAlreadyCompleteException. Add a unique parameter (like a timestamp) when you truly want a fresh run.
Quick Check
Test your error-handling knowledge.
Recap
You made batch jobs resilient:
- Restartability resumes a failed job from the last good point
skip+skipLimittolerates bad dataretry+retryLimithandles transient errors- Listeners audit skips/retries; keep writes idempotent
Sıkça Sorulan Sorular
“Yeniden Başlatma ve Hata Yönetimi” dersi ücretsiz mi?
Evet — “Yeniden Başlatma ve Hata Yönetimi” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Spring Boot 4 Microservices & REST APIs kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Spring Boot 4 Microservices & REST APIs kursu toplamda 4 dersten oluşur.
“Yeniden Başlatma ve Hata Yönetimi” dersinde ne öğreneceğim?
Toplu işlerindeki hatalardan kurtulun. Spring Boot 4 Microservices & REST APIs ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Spring Boot 4 Microservices & REST APIs öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Spring Boot 4 Microservices & REST APIs, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Yeniden Başlatma ve Hata Yönetimi” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Spring Boot 4 Microservices & REST APIs dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Spring Boot 4 Microservices & REST APIs dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- @Scheduled ile Zamanlama
- Spring Batch İşleri ve Adımları
- Okuyucular, İşleyiciler ve Yazıcılar
- Yeniden Başlatma ve Hata Yönetimi