Class AvroItemWriter<T>
java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.item.support.AbstractItemStreamItemWriter<T>
org.springframework.batch.item.avro.AvroItemWriter<T>
- All Implemented Interfaces:
ItemStream,ItemStreamWriter<T>,ItemWriter<T>
An
ItemWriter that serializes data to an WritableResource using Avro.
This does not support restart on failure.
This writer is not thread-safe.
- Since:
- 4.2
- Author:
- David Turanski, Mahmoud Ben Hassine
-
Constructor Summary
ConstructorsConstructorDescriptionAvroItemWriter(org.springframework.core.io.WritableResource resource, Class<T> clazz) This constructor will create an ItemWriter that does not embedded Avro schema.AvroItemWriter(org.springframework.core.io.WritableResource resource, org.springframework.core.io.Resource schema, Class<T> clazz) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()If any resources are needed for the stream to operate they need to be destroyed here.voidopen(ExecutionContext executionContext) Open the stream for the providedExecutionContext.voidProcess the supplied data element.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.batch.item.ItemStream
update
-
Constructor Details
-
AvroItemWriter
public AvroItemWriter(org.springframework.core.io.WritableResource resource, org.springframework.core.io.Resource schema, Class<T> clazz) - Parameters:
resource- aWritableResourceto which the objects will be serialized.schema- aResourcecontaining the Avro schema.clazz- the data type to be serialized.
-
AvroItemWriter
This constructor will create an ItemWriter that does not embedded Avro schema.- Parameters:
resource- aWritableResourceto which the objects will be serialized.clazz- the data type to be serialized.
-
-
Method Details
-
write
Description copied from interface:ItemWriterProcess the supplied data element. Will not be called with any null items in normal operation.- Parameters:
items- of items to be written. Must not benull.- Throws:
Exception- if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.
-
open
Description copied from interface:ItemStreamOpen the stream for the providedExecutionContext.- Parameters:
executionContext- current step'sExecutionContext. Will be the executionContext from the last run of the step on a restart.- See Also:
-
close
public void close()Description copied from interface:ItemStreamIf any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.
-