kagamihogeの日記

kagamihogeの日記です。

Spring Batch

Spring Cloud Stream(RabbitMQ)でhello-worldレベルのconsumer

Spring Cloud StreamをRabbitMQと組み合わせて、RabbitMQ管理画面から文字列をpublishしてspringアプリケーションでconsumeするだけのサンプルを作成する。 ソースコード・手順 build.gradle https://start.spring.io/ でCloud Stream, Spring for RabbitMQ…

Spring Batch 5さわる

Spring Batchは5.0から色々な変更が入った事を最近知った。 docs.spring.io What's new in Spring Batch 5 from ikeyat www.slideshare.net なので、良くやる設定などでとりあえず触ってみる。何分初めてさわるバージョンなので間違ってる事書いていたら申し…

spring-batchのMapJobRepositoryFactoryBeanがDeprecated

従来、メタテーブルを永続化しなくするためにMapJobRepositoryFactoryBeanを使う事があったがspring-batch v5.0で削除予定になったようだ。 * @deprecated as of v4.3 in favor or using the {@link JobRepositoryFactoryBean} * with an in-memory database…

spring-batchでJDBCのキーブレイク

背景 Javaでキーブレイク*1を意識することはあまり無い。JPAならOneToManyで自動的にコレクションにマッピングされるし、JSONやXMLでも同様である。 今回、spring-batchでO/Rをとある事情で使えずSQLを直接使用、かつ、キーブレイクが必要になった。その実現…

Spring Batch 4.2でメトリクスをPrometheus Pushgatewayにおくる

https://docs.spring.io/spring-batch/docs/current/reference/html/monitoring-and-metrics.html を試す。 Spring Batch 4.2はMicrometerベースのメトリクスを自動的に収集する。なので、プロパティでそのメトリクスの送信設定をすれば、データがそちらに送…

Spring Batch + MySQL + JTA(Atomikos)のUnable to commit new sequence value changes for BATCH_JOB_SEQ

現象 タイトル通りSpring Batch + MySQL + JTA(Atomikos)環境下で以下のような例外がスローされる。 Caused by: org.springframework.dao.DataAccessResourceFailureException: Unable to commit new sequence value changes for BATCH_JOB_SEQ at org.sprin…

Spring Boot 2.2.x + Spring Batchうごかす

Spring Batchのチュートリアル https://spring.io/guides/gs/batch-processing/ を動かします。このサンプルはいわゆるデータインポート処理で、CSVからデータ読み込み・変換・保存、を行います。 プロジェクト作成 Spring Bootの組み込みDB自動設定 build.g…

Spring Batchのstep間データ共有

Spring Batchでstep間でデータを共有する方法について。機能的に豊富では無いが、そこはSpring Batchとして積極的に提供する機能では無い、という設計判断なのだと思う。 以下ではそのやり方について述べる。 JobのExecutionContext JobのExecutionContextに…

spring-batchのJson読み込み

ソースコード plugins { id 'org.springframework.boot' version '2.2.2.RELEASE' id 'io.spring.dependency-management' version '1.0.8.RELEASE' id 'java' } dependencies { implementation 'org.springframework.boot:spring-boot-starter-batch' compil…

spring-batchでグループ単位のレコード読み込み

https://terasoluna-batch.github.io/guideline/5.0.0.RELEASE/ja/Ch05_FileAccess.html によると、コントロールブレイク処理(またはキーブレイク処理)、と呼ぶものをspring-batchで実現する方法について。 コントロールブレイク処理(またはキーブレイク処理…

spring-batchのPartitioningをためす

https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html#partitioning のPartitioningを試す。 ソースコード plugins { id 'org.springframework.boot' version '2.2.2.RELEASE' id 'io.spring.dependency-management' version …

spring-batchのRemote Chunkingをためす

https://docs.spring.io/spring-batch/docs/4.1.x/reference/html/spring-batch-integration.html#remote-chunking のRemote Chunkingをためす。 このサンプルは、Spring Integegration -> Active MQを介してMasterからworkerおprocessor + writerを呼び出す…

spring-batchのParallel Stepsをためす

https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html#scalabilityParallelSteps のパラレルstepを試す。http://kagamihoge.hatenablog.com/entry/2020/01/07/110847 は単一のstepをマルチスレッド化する方法だが、こちらは複…

spring-batchのTaskExecutorによるstepマルチスレッド化

https://docs.spring.io/spring-batch/docs/current/reference/html/scalability.html#scalability のMulti-threaded Stepを試す。 plugins { id 'org.springframework.boot' version '2.2.2.RELEASE' id 'io.spring.dependency-management' version '1.0.8.…

spring-batchのMapJobRepositoryFactoryBeanでメタテーブルをDBに保存せず大量にstepを実行するとスローダウン

現象 ほぼタイトルで言い切っているけど。spring-batchでメタデータ保存でDBを使わなないようインメモリに格納するMapJobRepositoryFactoryBeanを使う場合が稀に良くある。この状況下で大量のstepを含むjobを実行すると徐々に実行速度が低下していく、という…

spring-integrationでjob名渡してspring-batchを起動

spring-integration勉強中です。 spring-integrationに文字列でjob名を渡し、その先でspring-batchを起動、をつくる。https://github.com/pakmans/spring-batch-integration-example/blob/master/pom.xml を参考にした。

Spring Batch 4.1.x - Reference Documentation - Spring Batch Integrationのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/spring-batch-integration.html#springBatchIntegration https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Spring Batch Integration 1.1. Spring Batch Integratio…

Spring Batch 4.1.x - Reference Documentation - JSR-352 Supportのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/jsr-352.html#jsr-352 https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト *1 1. JSR-352 Support Spring Batch 3.0以降はJSR-352を完全に実装しています。このセクショ…

Spring Batch 4.1.x - Reference Documentation - Common Batch Patternsのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/common-patterns.html#commonPatterns https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Common Batch Patterns ある種のジョブはSpring Batch標準コンポーネントの…

Spring Batch 4.1.x - Reference Documentation - Unit Testingのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/testing.html#testing https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Unit Testing バッチ以外のアプリケーション同様に、バッチジョブの一部として書いたコード…

Spring Batch 4.1.x - Reference Documentation - Retryのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/retry.html#retry https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Retry 処理をロバストかつ失敗の可能性を下げるには、次回以降には成功する確率が高い場合、そ…

Spring Batch 4.1.x - Reference Documentation - Repeatのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/repeat.html#repeat https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Repeat 1.1. RepeatTemplate バッチ処理とは繰り返し処理であり、simple optimizationとなる…

Spring Batch 4.1.x - Reference Documentation - Scaling and Parallel Processingのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/scalability.html#scalability https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Scaling and Parallel Processing 大半のバッチ処理はシングルスレッド・シングル…

Spring Batch 4.1.x - Reference Documentation - ItemReaders and ItemWriters - 1.7-1.15のテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/readersAndWriters.html#readersAndWriters https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1.7. XML Item Readers and Writers Spring BatchはXMLを読み込みJavaオ…

Spring Batch 4.1.x - Reference Documentation - ItemReaders and ItemWriters - 1.1-1.6のテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/readersAndWriters.html#readersAndWriters https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. ItemReaders and ItemWriters すべてのバッチ処理は、大規模データの…

Spring Batch 4.1.x - Reference Documentation - Configuring a Stepのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/step.html#configureStep https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Configuring a Step ドメインのチャプターで解説したように、Stepは、バッチjobのシーケ…

Spring Batch 4.1.x - Reference Documentation - Configuring and Running a Jobのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/job.html#configureJob https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Configuring and Running a Job domain sectionでは、以下図を用いてアーキテクチャデザイ…

Spring Batch 4.1.x - Reference Documentation - The Domain Language of Batchのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/domain.html#domainLanguageOfBatch https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. The Domain Language of Batch 何らかの経験のあるバッチアーキテクトにとっ…

Spring Batch 4.1.x - Reference Documentation - What’s New in Spring Batch 4.1のテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/whatsnew.html#whatsNew https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. What’s New in Spring Batch 4.1 Spring Batch 4.1 releaseは以下の新機能があります。 @…

Spring Batch 4.1.x - Reference Documentation - Spring Batch Introductionのテキトー翻訳

https://docs.spring.io/spring-batch/4.1.x/reference/html/spring-batch-intro.html#spring-batch-intro https://qiita.com/kagamihoge/items/12fbbc2eac5b8a5ac1e0 俺の訳一覧リスト 1. Spring Batch Introduction エンタープライズ領域の多くのアプリケ…