spring-batch-rs 0.3.4

A toolkit for building enterprise-grade batch applications
Documentation
---
title: Spring Batch RS
description: Spring Batch patterns you know. Rust performance you need.
template: splash
hero:
  title: |
    Enterprise Batch Processing
    <span class="hero-gradient">Powered by Rust</span>
  tagline: Spring Batch patterns you know. Rust performance you need. No GC. No surprises.
  actions:
    - text: Get Started →
      link: /getting-started/
      icon: right-arrow
      variant: primary
    - text: View Examples
      link: /quick-examples/
      icon: document
      variant: minimal
---

import { LinkCard, CardGrid } from "@astrojs/starlight/components";

<div class="bench-section">
  <span class="bench-tag">Performance · benchmark reproductible</span>
  <h2>4.5× faster than Spring Batch Java</h2>
  <p class="bench-subtitle">10 million financial transactions · CSV → PostgreSQL → XML · same chunk size, same connection pool</p>
  <div class="bench-grid">
    <div class="bench-row">
      <span class="bench-label">Total pipeline</span>
      <div class="bench-track">
        <div class="bench-bar-rust" style="width: 22.5%">42s</div>
        <div class="bench-bar-java"></div>
      </div>
      <span class="bench-delta"><strong>4.5×</strong> faster · 187s</span>
    </div>
    <div class="bench-row">
      <span class="bench-label">Peak memory</span>
      <div class="bench-track">
        <div class="bench-bar-rust" style="width: 3.4%"></div>
        <div class="bench-bar-java"></div>
      </div>
      <span class="bench-delta"><strong>30×</strong> less · 62 MB vs 1 840 MB</span>
    </div>
    <div class="bench-row">
      <span class="bench-label">Cold start</span>
      <div class="bench-track">
        <div class="bench-bar-rust" style="width: 0.5%; min-width: 8px"></div>
        <div class="bench-bar-java"></div>
      </div>
      <span class="bench-delta"><strong>320×</strong> faster · &lt;10ms vs 3.2s</span>
    </div>
  </div>
  <div class="bench-legend">
    <span class="bench-legend-item"><span class="bench-dot bench-dot-rust"></span>Spring Batch RS (Rust)</span>
    <span class="bench-legend-item"><span class="bench-dot bench-dot-java"></span>Spring Batch (Java)</span>
  </div>
  <a href="/reference/java-vs-rust-benchmark/" class="bench-link">→ Methodology, full numbers &amp; how to reproduce</a>
</div>

<div class="code-showcase">
  <div class="showcase-header">
    <div class="header-badge">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <polyline points="16 18 22 12 16 6"/>
        <polyline points="8 6 2 12 8 18"/>
      </svg>
      <span>LIVE EXAMPLE</span>
    </div>
    <h2>CSV → JSON Pipeline</h2>
    <p>Type-safe, fault-tolerant, zero boilerplate</p>
  </div>

```rust
use spring_batch_rs::prelude::*;

// 1. Define your data shape — Rust enforces type safety at compile time
#[derive(Deserialize, Serialize)]
struct Product {
    id: u32,
    name: String,
    price: f64,
}

// 2. Configure source and destination using builder patterns
let reader = CsvItemReaderBuilder::<Product>::new()
    .from_path("products.csv")
    .has_headers(true)
    .build();

// Passthrough processor — forwards items unchanged (swap in your own logic here)
let processor = PassThroughProcessor::<Product>::new();

let writer = JsonItemWriterBuilder::<Product>::new()
    .from_path("products.json");

// 3. Build the pipeline
//    chunk(100)      → accumulate 100 items, then write once (balances I/O vs memory)
//    skip_limit(10)  → tolerate up to 10 bad records before the job fails
let step = StepBuilder::new("convert-products")
    .reader(&reader)
    .processor(&processor)
    .writer(&writer)
    .chunk(100)
    .skip_limit(10)
    .build();

// 4. Run — the job tracks status, counts, and errors automatically
JobBuilder::new().start(&step).build().run();
```
  <div class="showcase-footer">
    <a href="https://github.com/sboussekeyt/spring-batch-rs/blob/main/examples/csv_processing.rs" class="showcase-source-link">→ View full source on GitHub</a>
  </div>
</div>


<CardGrid>
  <LinkCard
    title="Getting Started"
    description="First batch job in 5 minutes. Installation, setup, first example."
    href="/getting-started/"
  />
  <LinkCard
    title="Java vs Rust Benchmark"
    description="Methodology, full numbers & how to reproduce on your own infrastructure."
    href="/reference/java-vs-rust-benchmark/"
  />
  <LinkCard
    title="Examples Gallery"
    description="24+ pipelines with links to source code on GitHub."
    href="/quick-examples/"
  />
  <LinkCard
    title="Architecture"
    description="Job → Step → Reader/Processor/Writer. Chunk-oriented processing."
    href="/architecture/"
  />
</CardGrid>