Class AbstractKafkaProtobufSerializer<T extends com.google.protobuf.Message>
java.lang.Object
io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
io.confluent.kafka.serializers.protobuf.AbstractKafkaProtobufSerializer<T>
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
KafkaProtobufSerializer
public abstract class AbstractKafkaProtobufSerializer<T extends com.google.protobuf.Message>
extends AbstractKafkaSchemaSerDe
-
Nested Class Summary
Nested classes/interfaces inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
AbstractKafkaSchemaSerDe.ExtendedSchema, AbstractKafkaSchemaSerDe.Migration, AbstractKafkaSchemaSerDe.SubjectSchema -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected ReferenceSubjectNameStrategyprotected Stringprotected booleanprotected intFields inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
config, configOriginals, contextNameStrategy, DEFAULT_CACHE_CAPACITY, enableRuleServiceLoader, executionEnv, isKey, keySchemaIdDeserializer, keySchemaIdSerializer, keySubjectNameStrategy, latestVersions, latestWithMetadata, metadata, ruleActions, ruleExecutors, schemaRegistry, ticker, useLatestVersion, useSchemaReflection, valueSchemaIdDeserializer, valueSchemaIdSerializer, valueSubjectNameStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidstatic ProtobufSchemaresolveDependencies(SchemaRegistryClient schemaRegistry, boolean normalizeSchema, boolean autoRegisterSchema, boolean propagateSchemaTags, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) Resolve schema dependencies recursively.static ProtobufSchemaresolveDependencies(SchemaRegistryClient schemaRegistry, boolean normalizeSchema, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) static ProtobufSchemaresolveDependencies(SchemaRegistryClient schemaRegistry, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) Resolve schema dependencies recursively.static ProtobufSchemaresolveDependencies(SchemaRegistryClient schemaRegistry, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) Resolve schema dependencies recursively.protected byte[]serializeImpl(String subject, String topic, boolean isKey, org.apache.kafka.common.header.Headers headers, T object, ProtobufSchema schema) protected byte[]serializeImpl(String subject, String topic, boolean isKey, T object, ProtobufSchema schema) protected KafkaProtobufSerializerConfigserializerConfig(Map<String, ?> props) Methods inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
clearKey, close, configureClientProperties, executeMigrations, executeRules, executeRules, executeRules, getById, getBySubjectAndId, getContextName, getContextName, getLatestWithMetadata, getMigrations, getOldSubjectName, getRuleActions, getRuleExecutors, getSchemaById, getSchemaBySchemaId, getSchemaBySubjectAndId, getSchemaRegistryClient, getSubjectName, isKey, key, latestVersionsCache, latestWithMetadataCache, lookupLatestVersion, lookupLatestVersion, lookupSchemaBySubjectAndId, postOp, register, register, register, registerWithResponse, schemaIdDeserializer, schemaIdSerializer, setKey, strategyUsesSchema, ticker, toKafkaException
-
Field Details
-
normalizeSchema
protected boolean normalizeSchema -
autoRegisterSchema
protected boolean autoRegisterSchema -
propagateSchemaTags
protected boolean propagateSchemaTags -
onlyLookupReferencesBySchema
protected boolean onlyLookupReferencesBySchema -
useSchemaId
protected int useSchemaId -
idCompatStrict
protected boolean idCompatStrict -
latestCompatStrict
protected boolean latestCompatStrict -
schemaFormat
-
skipKnownTypes
protected boolean skipKnownTypes -
referenceSubjectNameStrategy
-
-
Constructor Details
-
AbstractKafkaProtobufSerializer
public AbstractKafkaProtobufSerializer()
-
-
Method Details
-
configure
-
serializerConfig
-
serializeImpl
protected byte[] serializeImpl(String subject, String topic, boolean isKey, T object, ProtobufSchema schema) throws org.apache.kafka.common.errors.SerializationException, org.apache.kafka.common.errors.InvalidConfigurationException - Throws:
org.apache.kafka.common.errors.SerializationExceptionorg.apache.kafka.common.errors.InvalidConfigurationException
-
serializeImpl
protected byte[] serializeImpl(String subject, String topic, boolean isKey, org.apache.kafka.common.header.Headers headers, T object, ProtobufSchema schema) throws org.apache.kafka.common.errors.SerializationException, org.apache.kafka.common.errors.InvalidConfigurationException - Throws:
org.apache.kafka.common.errors.SerializationExceptionorg.apache.kafka.common.errors.InvalidConfigurationException
-
resolveDependencies
public static ProtobufSchema resolveDependencies(SchemaRegistryClient schemaRegistry, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) throws IOException, RestClientExceptionResolve schema dependencies recursively.- Parameters:
schemaRegistry- schema registry clientautoRegisterSchema- whether to automatically register schemasuseLatestVersion- whether to use the latest subject version for serializationlatestCompatStrict- whether to check that the latest subject version is backward compatible with the schema of the objectlatestVersions- an optional cache of latest subject versions, may be nullstrategy- the strategy for determining the subject name for a referencetopic- the topicisKey- whether the object is the record keyschema- the schema- Returns:
- the schema with resolved dependencies
- Throws:
IOExceptionRestClientException
-
resolveDependencies
public static ProtobufSchema resolveDependencies(SchemaRegistryClient schemaRegistry, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) throws IOException, RestClientExceptionResolve schema dependencies recursively.- Parameters:
schemaRegistry- schema registry clientautoRegisterSchema- whether to automatically register schemasuseLatestVersion- whether to use the latest subject version for serializationlatestCompatStrict- whether to check that the latest subject version is backward compatible with the schema of the objectlatestVersions- an optional cache of latest subject versions, may be nullskipKnownTypes- whether to skip known types when resolving schema dependenciesstrategy- the strategy for determining the subject name for a referencetopic- the topicisKey- whether the object is the record keyschema- the schema- Returns:
- the schema with resolved dependencies
- Throws:
IOExceptionRestClientException
-
resolveDependencies
public static ProtobufSchema resolveDependencies(SchemaRegistryClient schemaRegistry, boolean normalizeSchema, boolean autoRegisterSchema, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) throws IOException, RestClientException- Throws:
IOExceptionRestClientException
-
resolveDependencies
public static ProtobufSchema resolveDependencies(SchemaRegistryClient schemaRegistry, boolean normalizeSchema, boolean autoRegisterSchema, boolean propagateSchemaTags, boolean useLatestVersion, boolean latestCompatStrict, Map<AbstractKafkaSchemaSerDe.SubjectSchema, AbstractKafkaSchemaSerDe.ExtendedSchema> latestVersions, boolean skipKnownTypes, ReferenceSubjectNameStrategy strategy, String topic, boolean isKey, ProtobufSchema schema) throws IOException, RestClientExceptionResolve schema dependencies recursively.- Parameters:
schemaRegistry- schema registry clientnormalizeSchema- whether to normalized the schemaautoRegisterSchema- whether to automatically register schemaspropagateSchemaTags- whether to propagate tags during registrationuseLatestVersion- whether to use the latest subject version for serializationlatestCompatStrict- whether to check that the latest subject version is backward compatible with the schema of the objectlatestVersions- an optional cache of latest subject versions, may be nullskipKnownTypes- whether to skip known types when resolving schema dependenciesstrategy- the strategy for determining the subject name for a referencetopic- the topicisKey- whether the object is the record keyschema- the schema- Returns:
- the schema with resolved dependencies
- Throws:
IOExceptionRestClientException
-