public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessageConverter implements org.springframework.beans.factory.InitializingBean
MessageConverter
for Apache Avro,
with the ability to publish and retrieve schemas stored in a schema server, allowing
for schema evolution in applications. The supported content types are in the form
`application/*+avro`.
During the conversion to a message, the converter will set the 'contentType' header to
'application/[prefix].[subject].v[version]+avro', where:
SchemaRegistryClient
.Modifier and Type | Field and Description |
---|---|
static String |
AVRO_FORMAT |
static String |
CACHE_PREFIX |
static Pattern |
PREFIX_VALIDATION_PATTERN |
static String |
REFERENCE_CACHE_NAME |
static String |
REFLECTION_CACHE_NAME |
static String |
SCHEMA_CACHE_NAME |
Constructor and Description |
---|
AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient)
Creates a new instance, configuring it with a
SchemaRegistryClient . |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
boolean |
isDynamicSchemaGenerationEnabled() |
protected org.apache.avro.Schema |
resolveReaderSchemaForDeserialization(Class<?> targetClass) |
protected org.apache.avro.Schema |
resolveSchemaForWriting(Object payload,
org.springframework.messaging.MessageHeaders headers,
org.springframework.util.MimeType hintedContentType) |
protected org.apache.avro.Schema |
resolveWriterSchemaForDeserialization(org.springframework.util.MimeType mimeType) |
void |
setCacheManager(org.springframework.cache.CacheManager cacheManager) |
void |
setDynamicSchemaGenerationEnabled(boolean dynamicSchemaGenerationEnabled)
Allows the converter to generate and register schemas automatically.
|
void |
setPrefix(String prefix)
Set the prefix to be used in the publised subtype.
|
void |
setReaderSchema(org.springframework.core.io.Resource readerSchema) |
void |
setSchemaLocations(org.springframework.core.io.Resource[] schemaLocations)
A set of locations where the converter can load schemas from.
|
protected boolean |
supports(Class<?> clazz) |
protected boolean |
supportsMimeType(org.springframework.messaging.MessageHeaders headers) |
protected String |
toSubject(org.apache.avro.Schema schema) |
canConvertFrom, convertFromInternal, convertToInternal, getDatumReader, parseSchema
canConvertTo, convertFromInternal, convertToInternal, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, toMessage, toMessage
public static final String AVRO_FORMAT
public static final Pattern PREFIX_VALIDATION_PATTERN
public static final String CACHE_PREFIX
public static final String REFLECTION_CACHE_NAME
public static final String SCHEMA_CACHE_NAME
public static final String REFERENCE_CACHE_NAME
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient)
SchemaRegistryClient
.schemaRegistryClient
- the SchemaRegistryClient
used to interact with
the schema registry server.public boolean isDynamicSchemaGenerationEnabled()
public void setDynamicSchemaGenerationEnabled(boolean dynamicSchemaGenerationEnabled)
dynamicSchemaGenerationEnabled
- true if dynamic schema generation is enabledpublic void setSchemaLocations(org.springframework.core.io.Resource[] schemaLocations)
schemaLocations
- public void setPrefix(String prefix)
prefix
- public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
protected String toSubject(org.apache.avro.Schema schema)
protected boolean supports(Class<?> clazz)
supports
in class org.springframework.messaging.converter.AbstractMessageConverter
protected boolean supportsMimeType(org.springframework.messaging.MessageHeaders headers)
supportsMimeType
in class org.springframework.messaging.converter.AbstractMessageConverter
protected org.apache.avro.Schema resolveSchemaForWriting(Object payload, org.springframework.messaging.MessageHeaders headers, org.springframework.util.MimeType hintedContentType)
resolveSchemaForWriting
in class AbstractAvroMessageConverter
protected org.apache.avro.Schema resolveWriterSchemaForDeserialization(org.springframework.util.MimeType mimeType)
resolveWriterSchemaForDeserialization
in class AbstractAvroMessageConverter
protected org.apache.avro.Schema resolveReaderSchemaForDeserialization(Class<?> targetClass)
resolveReaderSchemaForDeserialization
in class AbstractAvroMessageConverter
public void setReaderSchema(org.springframework.core.io.Resource readerSchema)
public void setCacheManager(org.springframework.cache.CacheManager cacheManager)
Copyright © 2017 Pivotal Software, Inc.. All rights reserved.