Appendix A: List of ItemReaders and ItemWriters

A.1. Item Readers

Table 1. Available Item Readers

Item ReaderDescription
AbstractItemCountingItemStreamItemReaderAbstract base class that provides basic restart capabilities by counting the number of items returned from an ItemReader .
AggregateItemReaderAn ItemReader that delivers a list as its item, storing up objects from the injected ItemReader until they are ready to be packed out as a collection. This class must be used as a wrapper for a custom ItemReader that can identify the record boundaries. The custom reader should mark the beginning and end of records by returning an AggregateItem which responds true to its query methods isHeader() and isFooter() . Note that this reader is not part of the library of readers provided by Spring Batch but given as a sample in spring-batch-samples .
AmqpItemReaderGiven a Spring AmqpTemplate , it provides synchronous receive methods. The receiveAndConvert() method lets you receive POJO objects.
FlatFileItemReaderReads from a flat file. Includes ItemStream and Skippable functionality. See FlatFileItemReader.
HibernateCursorItemReaderReads from a cursor based on an HQL query. See Cursor-based ItemReaders.
HibernatePagingItemReaderReads from a paginated HQL query
ItemReaderAdapterAdapts any class to the ItemReader interface.
JdbcCursorItemReaderReads from a database cursor via JDBC. See Cursor-based ItemReaders.
JdbcPagingItemReaderGiven an SQL statement, pages through the rows, such that large datasets can be read without running out of memory.
JmsItemReaderGiven a Spring JmsOperations object and a JMS Destination or destination name to which to send errors, provides items received through the injected JmsOperations#receive() method.
JpaPagingItemReaderGiven a JPQL statement, pages through the rows, such that large datasets can be read without running out of memory.
ListItemReaderProvides the items from a list, one at a time.
MongoItemReaderGiven a MongoOperations object and a JSON-based MongoDB query, provides items received from the MongoOperations#find() method.
Neo4jItemReaderGiven a Neo4jOperations object and the components of a Cyhper query, items are returned as the result of the Neo4jOperations.query method.
RepositoryItemReaderGiven a Spring Data PagingAndSortingRepository object, a Sort , and the name of method to execute, returns items provided by the Spring Data repository implementation.
StoredProcedureItemReaderReads from a database cursor resulting from the execution of a database stored procedure. See StoredProcedureItemReader
StaxEventItemReaderReads via StAX. see StaxEventItemReader.
JsonItemReaderReads items from a Json document. see JsonItemReader.

A.2. Item Writers

Table 2. Available Item Writers

Item WriterDescription
AbstractItemStreamItemWriterAbstract base class that combines the ItemStream and ItemWriter interfaces.
AmqpItemWriterGiven a Spring AmqpTemplate , it provides for a synchronous send method. The convertAndSend(Object) method lets you send POJO objects.
CompositeItemWriterPasses an item to the write method of each in an injected List of ItemWriter objects.
FlatFileItemWriterWrites to a flat file. Includes ItemStream and Skippable functionality. See FlatFileItemWriter.
GemfireItemWriterUsing a GemfireOperations object, items are either written or removed from the Gemfire instance based on the configuration of the delete flag.
HibernateItemWriterThis item writer is Hibernate-session aware and handles some transaction-related work that a non-"hibernate-aware" item writer would not need to know about and then delegates to another item writer to do the actual writing.
ItemWriterAdapterAdapts any class to the ItemWriter interface.
JdbcBatchItemWriterUses batching features from a PreparedStatement , if available, and can take rudimentary steps to locate a failure during a flush .
JmsItemWriterUsing a JmsOperations object, items are written to the default queue through the JmsOperations#convertAndSend() method.
JpaItemWriterThis item writer is JPA EntityManager-aware and handles some transaction-related work that a non-"JPA-aware" ItemWriter would not need to know about and then delegates to another writer to do the actual writing.
MimeMessageItemWriterUsing Spring’s JavaMailSender , items of type MimeMessage are sent as mail messages.
MongoItemWriterGiven a MongoOperations object, items are written through the method. The actual write is delayed until the last possible moment before the transaction commits.
Neo4jItemWriterGiven a Neo4jOperations object, items are persisted through the save(Object) method or deleted through the delete(Object) per the ItemWriter’s configuration
PropertyExtractingDelegatingItemWriterExtends AbstractMethodInvokingDelegator creating arguments on the fly. Arguments are created by retrieving the values from the fields in the item to be processed (through a SpringBeanWrapper ), based on an injected array of field names.
RepositoryItemWriterGiven a Spring Data CrudRepository implementation, items are saved through the method specified in the configuration.
StaxEventItemWriterUses a Marshaller implementation to convert each item to XML and then writes it to an XML file using StAX.
JsonFileItemWriterUses a JsonObjectMarshaller implementation to convert each item to Json and then writes it to an Json file.