Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring Batchの紹介

Spring Batchの紹介

2018.4.11 社内勉強会で発表した
Spring Batch実行環境のスライド

9a71d9081335ef7d5ecfa86155c949af?s=128

yutachaos

April 12, 2018
Tweet

Transcript

  1. Spring Batch ղઆ 2018/4/11
 
 ໦ଜ༐ଠ

  2. AGENDA • Spring Batchͱ͸ • Ϣʔεέʔε • ΞʔΩςΫνϟ • ·ͱΊɹ

  3. Spring Batchͱ͸ • Java੡ • Spring ProjectͷBatch޲͚ͷϑϨʔϜϫʔΫ • SpringͷDIίϯςφɺAOPɺτϥϯβΫγϣϯػೳΛϕʔεʹ࡞੒ ͞Ε͍ͯΔ

    ϩΰ
  4. SpringΛCOREͱͨ͠ɺJavaͷEnterprise޲͚ͷιϑτ΢ΣΞ Spring Projectͱ͸ • Spring Boot • Spring Batch •

    Spring Framework • Spring Cloud • Spring Shell • Spring Social • Spring LADP • ɾɾɾetc ͍ͬͺ͍͋Γ·͢ɻ
  5. Ϣʔεέʔε • େྔσʔλͷBatchॲཧ • ༷ʑͳϦιʔεʹରԠ • DB, S3, http(s), fileͳͲSpringͷResourceLoaderͷࢿ࢈͕࢖͑Δ

    • ܗࣜ • CSV, TSV, json ,DBͳͲΛmappingͯ͠ϑΝΠϧʹಡΈࠐΈରԠՄ ೳ
  6. Spring Batch ΞʔΩςΫνϟ

  7. Spring Batch ղઆ 1 • JobશମͷྲྀΕ͸JobRepository͕؅ཧ • Job͕1ͭͷେ͖ͳॲཧΛ؅ཧ • Stepͷॲཧ͸ݻఆ਺෼ׂɺಈతʹՄม෼ׂͷ୯ҐͰฒߦॲཧΛߦ͏

    ͜ͱ͕ग़དྷΔɻ
  8. Spring Batch StepΞʔΩςΫνϟ(Chunk)

  9. Spring Batch StepΞʔΩςΫνϟ(Tasklet)

  10. Spring Batch ղઆ 2 • ॲཧϞσϧ • Chunk • Ұఆ݅਺ͷσʔλ͝ͱʹ·ͱΊͯͷread(ಡΈࠐΈ)ɺprocess(Ճ޻)ɺ

    write(ॻ͖ࠐΈ)ͷྲྀΕͰॲཧ͢ΔํࣜɻॲཧͷྲྀΕΛఆܕԽ͠ɺ Ұ෦Λ ࣮૷͢Δ͚ͩͰδϣϒ͕࣮૷Ͱ͖Δɻ • Tasklet • ࣗ༝ʹॲཧΛهड़͢ΔํࣜͰ͋ΔɻSQLΛ1ճൃߦ͢Δ͚ͩɺίϚϯυΛ ൃߦ͢Δ͚ͩɺͱ͍ͬͨ؆ૉͳέʔε΍ ෳ਺ͷσʔλϕʔε΍ϑΝΠϧʹ ΞΫηε͠ͳ͕Βॲཧ͢ΔΑ͏ͳෳࡶͰఆܕԽ͠ʹ͍͘έʔεͰ༻͍Δɻ
  11. KFCͷ৔߹ Spring Batch ར༻ྫ • େ͖͘෼͚ͯɺ2ͭͷॲཧ • ूܭ͞ΕͨσʔλΛϚΠϧσʔλͷDBʹInsert͢Δ (ॲཧ1) •

    ूܭ͞ΕͨσʔλΛར༻ͯ͠ɺpush௨஌ͷͨΊͷAPI callͱΞϓϦ ଆͷDBͷߋ৽ (ॲཧ2) • ࣮ߦํ๏ • JenkinsΛJob Schedulerʹར༻͠ɺίϚϯυϥΠϯͰ࣮ߦ
  12. ·ͱΊ • σϝϦοτ • JavaɺSpringͷ஌͕ࣝඞཁ • Springࣗମͷίʔυϕʔε͕๲େͳͷͰɺSpringͷ಺෦·ͰೖΓࠐΜ ͩ໰୊ʹରԠͮ͠Β͍ɻ • ϝϦοτ

    • Springͷࢿ࢈͕ར༻ग़དྷΔͷͰɺ৘ใ͕ଟ͍ɻ • ࠶࣮ߦɺฒྻॲཧɺ੒ޭɾࣦഊͳͲͷॲཧϑϩʔ͕طʹFWʹؚ·Εͯ ͍ΔͷͰɺ৺഑͢Δ͜ͱ͕গͳͯ͘ࡁΉ
  13. ͓ΘΓ

  14. • ࢀߟจݙ • Macchinetta Batch Framework Development Guideline • TERASOLUNA

    Batch Framework for Java (5.x) Development Guideline • 20170525 jsug όον͸஍ຯ͕ͩ໾ʹཱͭ • https://www.slideshare.net/HasegawaDanna1/20170525-jsug