Class AvroSchemaMessageConverter
- java.lang.Object
-
- org.springframework.messaging.converter.AbstractMessageConverter
-
- org.springframework.cloud.function.context.converter.avro.AbstractAvroMessageConverter
-
- org.springframework.cloud.function.context.converter.avro.AvroSchemaMessageConverter
-
- All Implemented Interfaces:
org.springframework.messaging.converter.MessageConverter,org.springframework.messaging.converter.SmartMessageConverter
public class AvroSchemaMessageConverter extends AbstractAvroMessageConverter
AMessageConverterusing Apache Avro. The schema for serializing and deserializing will be automatically inferred from the class forSpecificRecordand regular classes, unless a specific schema is set, case in which that schema will be used instead. For converting toGenericRecordtargets, a schema must be set.s- Since:
- 3.2.0
- Author:
- Marius Bogoevici, Ish Mahajan, Soby Chacko
-
-
Constructor Summary
Constructors Constructor Description AvroSchemaMessageConverter(Collection<org.springframework.util.MimeType> supportedMimeTypes, AvroSchemaServiceManager manager)Create aAvroSchemaMessageConverter.AvroSchemaMessageConverter(AvroSchemaServiceManager manager)Create aAvroSchemaMessageConverter.AvroSchemaMessageConverter(org.springframework.util.MimeType supportedMimeType, AvroSchemaServiceManager manager)Create aAvroSchemaMessageConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.avro.SchemagetSchema()protected org.apache.avro.SchemaresolveReaderSchemaForDeserialization(Class<?> targetClass)protected org.apache.avro.SchemaresolveSchemaForWriting(Object payload, org.springframework.messaging.MessageHeaders headers, org.springframework.util.MimeType hintedContentType)protected org.apache.avro.SchemaresolveWriterSchemaForDeserialization(org.springframework.util.MimeType mimeType)voidsetSchema(org.apache.avro.Schema schema)Sets the Apache Avro schema to be used by this converter.voidsetSchemaLocation(org.springframework.core.io.Resource schemaLocation)The location of the Apache Avro schema to be used by this converter.protected booleansupports(Class<?> clazz)-
Methods inherited from class org.springframework.cloud.function.context.converter.avro.AbstractAvroMessageConverter
avroSchemaServiceManager, canConvertFrom, convertFromInternal, convertToInternal, parseSchema
-
Methods inherited from class org.springframework.messaging.converter.AbstractMessageConverter
addSupportedMimeTypes, canConvertTo, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
-
-
-
-
Constructor Detail
-
AvroSchemaMessageConverter
public AvroSchemaMessageConverter(AvroSchemaServiceManager manager)
- Parameters:
manager- for schema management
-
AvroSchemaMessageConverter
public AvroSchemaMessageConverter(org.springframework.util.MimeType supportedMimeType, AvroSchemaServiceManager manager)Create aAvroSchemaMessageConverter. The converter will be used for the providedMimeType.- Parameters:
supportedMimeType- mime type to be supported byAvroSchemaMessageConvertermanager- for schema management
-
AvroSchemaMessageConverter
public AvroSchemaMessageConverter(Collection<org.springframework.util.MimeType> supportedMimeTypes, AvroSchemaServiceManager manager)
Create aAvroSchemaMessageConverter. The converter will be used for the providedMimeTypes.- Parameters:
supportedMimeTypes- the mime types supported by this convertermanager- for schema management
-
-
Method Detail
-
getSchema
public org.apache.avro.Schema getSchema()
-
setSchema
public void setSchema(org.apache.avro.Schema schema)
Sets the Apache Avro schema to be used by this converter.- Parameters:
schema- schema to be used by this converter
-
setSchemaLocation
public void setSchemaLocation(org.springframework.core.io.Resource schemaLocation)
The location of the Apache Avro schema to be used by this converter.- Parameters:
schemaLocation- the location of the schema used by this converter.
-
supports
protected boolean supports(Class<?> clazz)
- Specified by:
supportsin classorg.springframework.messaging.converter.AbstractMessageConverter
-
resolveWriterSchemaForDeserialization
protected org.apache.avro.Schema resolveWriterSchemaForDeserialization(org.springframework.util.MimeType mimeType)
- Specified by:
resolveWriterSchemaForDeserializationin classAbstractAvroMessageConverter
-
resolveReaderSchemaForDeserialization
protected org.apache.avro.Schema resolveReaderSchemaForDeserialization(Class<?> targetClass)
- Specified by:
resolveReaderSchemaForDeserializationin classAbstractAvroMessageConverter
-
resolveSchemaForWriting
protected org.apache.avro.Schema resolveSchemaForWriting(Object payload, org.springframework.messaging.MessageHeaders headers, org.springframework.util.MimeType hintedContentType)
- Specified by:
resolveSchemaForWritingin classAbstractAvroMessageConverter
-
-