Class JsonSchemaKafkaSerializer<T>
java.lang.Object
io.apicurio.registry.serde.SchemaResolverConfigurer<T,U>
io.apicurio.registry.serde.AbstractKafkaSerDe<T,U>
io.apicurio.registry.serde.AbstractKafkaSerializer<JsonSchema,T>
io.apicurio.registry.serde.jsonschema.JsonSchemaKafkaSerializer<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.kafka.common.serialization.Serializer<T>
public class JsonSchemaKafkaSerializer<T>
extends AbstractKafkaSerializer<JsonSchema,T>
implements org.apache.kafka.common.serialization.Serializer<T>
An implementation of the Kafka Serializer for JSON Schema use-cases. This serializer assumes that the
user's application needs to serialize a Java Bean to JSON data using Jackson. In addition to standard
serialization of the bean, this implementation can also optionally validate it against a JSON schema.
- Author:
- eric.wittmann@gmail.com, Ales Justin, Fabian Martinez, Carles Arnal
-
Field Summary
Fields inherited from class io.apicurio.registry.serde.AbstractKafkaSerDe
headersHandler, idHandler, key, log, MAGIC_BYTEFields inherited from class io.apicurio.registry.serde.SchemaResolverConfigurer
schemaResolver -
Constructor Summary
ConstructorsConstructorDescriptionJsonSchemaKafkaSerializer(io.apicurio.registry.resolver.SchemaResolver<JsonSchema, T> schemaResolver) JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client) JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<JsonSchema, T> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<JsonSchema, T> schemaResolver) JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, Boolean validationEnabled) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanio.apicurio.registry.resolver.SchemaParser<JsonSchema,T> protected voidserializeData(io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) protected voidserializeData(org.apache.kafka.common.header.Headers headers, io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) voidsetValidationEnabled(Boolean validationEnabled) Methods inherited from class io.apicurio.registry.serde.AbstractKafkaSerializer
close, serialize, serializeMethods inherited from class io.apicurio.registry.serde.AbstractKafkaSerDe
asLegacyId, configure, getByteBuffer, getIdHandler, isKey, reset, setHeadersHandler, setIdHandlerMethods inherited from class io.apicurio.registry.serde.SchemaResolverConfigurer
configure, getSchemaResolver, setSchemaResolverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.common.serialization.Serializer
close, serialize, serialize
-
Constructor Details
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer() -
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<JsonSchema, T> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<JsonSchema, T> schemaResolver) -
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client) -
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.resolver.SchemaResolver<JsonSchema, T> schemaResolver) -
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, Boolean validationEnabled)
-
-
Method Details
-
configure
- Specified by:
configurein interfaceorg.apache.kafka.common.serialization.Serializer<T>- Overrides:
configurein classAbstractKafkaSerializer<JsonSchema,T> - See Also:
-
isValidationEnabled
public boolean isValidationEnabled() -
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
setValidationEnabled
- Parameters:
validationEnabled- the validationEnabled to set
-
schemaParser
- Specified by:
schemaParserin classAbstractKafkaSerDe<JsonSchema,T> - See Also:
-
serializeData
protected void serializeData(io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) throws IOException - Specified by:
serializeDatain classAbstractKafkaSerializer<JsonSchema,T> - Throws:
IOException- See Also:
-
io.apicurio.registry.serde.AbstractKafkaSerializer#serializeData(io.apicurio.registry.serde.ParsedSchema, java.lang.Object, java.io.OutputStream)
-
serializeData
protected void serializeData(org.apache.kafka.common.header.Headers headers, io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) throws IOException - Specified by:
serializeDatain classAbstractKafkaSerializer<JsonSchema,T> - Throws:
IOException- See Also:
-
io.apicurio.registry.serde.AbstractKafkaSerializer#serializeData(org.apache.kafka.common.header.Headers, io.apicurio.registry.serde.ParsedSchema, java.lang.Object, java.io.OutputStream)
-