Skip to content

API Reference

Spring Batch RS is built around four core traits that define the batch processing model.

graph TD
    subgraph "Core Traits"
        IR[ItemReader<I>]
        IP[ItemProcessor<I, O>]
        IW[ItemWriter<O>]
        T[Tasklet]
    end

    subgraph "Data Flow"
        IR -->|"read() -> Option<I>"| IP
        IP -->|"process(&I) -> O"| IW
        IW -->|"write(&[O])"| Output[Output]
    end

    subgraph "Single Task"
        T -->|"execute()"| Result[Result]
    end
TraitMethodReturnsPurpose
ItemReader<I>read(&self)Result<Option<I>, BatchError>Read next item
ItemProcessor<I,O>process(&self, &I)Result<O, BatchError>Transform item
ItemWriter<O>write(&self, &[O])Result<(), BatchError>Write batch
ItemWriter<O>open(&self)Result<(), BatchError>Initialize writer
ItemWriter<O>close(&self)Result<(), BatchError>Finalize writer
ItemWriter<O>flush(&self)Result<(), BatchError>Flush buffers
pub type ItemReaderResult<I> = Result<Option<I>, BatchError>;
pub type ItemProcessorResult<O> = Result<O, BatchError>;
pub type ItemWriterResult = Result<(), BatchError>;
FeatureReaderDescription
csvCsvItemReader<R>CSV files and strings
jsonJsonItemReader<I, R>Streaming JSON arrays
xmlXmlItemReader<R, I>XML documents
rdbc-postgresPostgresRdbcItemReader<I>PostgreSQL queries
rdbc-mysqlMysqlRdbcItemReader<I>MySQL/MariaDB queries
rdbc-sqliteSqliteRdbcItemReader<I>SQLite queries
mongodbMongodbItemReader<I>MongoDB collections
ormOrmItemReader<I>SeaORM entities
fakePersonReaderFake test data
FeatureWriterDescription
csvCsvItemWriter<O, W>CSV files
jsonJsonItemWriter<O, W>JSON arrays
xmlXmlItemWriter<O, W>XML documents
rdbc-postgresPostgresItemWriter<O>PostgreSQL inserts
rdbc-mysqlMysqlItemWriter<O>MySQL inserts
rdbc-sqliteSqliteItemWriter<O>SQLite inserts
mongodbMongodbItemWriter<O>MongoDB inserts
ormOrmItemWriter<O>SeaORM inserts
loggerLoggerWriterDebug logging