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
ConstructorDescriptionAvroItemWriter
(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 TypeMethodDescriptionvoid
close()
If any resources are needed for the stream to operate they need to be destroyed here.void
open
(ExecutionContext executionContext) Open the stream for the providedExecutionContext
.void
Process the supplied data element.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
- aWritableResource
to which the objects will be serialized.schema
- aResource
containing 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
- aWritableResource
to which the objects will be serialized.clazz
- the data type to be serialized.
-
-
Method Details
-
write
Description copied from interface:ItemWriter
Process 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:ItemStream
Open 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:ItemStream
If 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.
-