Class KeyValueSerdeResolver
java.lang.Object
org.springframework.cloud.stream.binder.kafka.streams.KeyValueSerdeResolver
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class KeyValueSerdeResolver
extends Object
implements org.springframework.context.ApplicationContextAware
Resolver for key and value Serde.
On the inbound, if native decoding is enabled, then any deserialization on the value is
handled by Kafka. First, we look for any key/value Serde set on the binding itself, if
that is not available then look at the common Serde set at the global level. If that
fails, it falls back to byte[]. If native decoding is disabled, then the binder will do
the deserialization on value and ignore any Serde set for value and rely on the
contentType provided. Keys are always deserialized at the broker.
Same rules apply on the outbound. If native encoding is enabled, then value
serialization is done at the broker using any binder level Serde for value, if not
using common Serde, if not, then byte[]. If native encoding is disabled, then the
binder will do serialization using a contentType. Keys are always serialized by the
broker.
For state store, use serdes class specified in
KafkaStreamsStateStore
to create Serde accordingly.- Author:
- Soby Chacko, Lei Chen, Eduard DomÃnguez, Chris Bono
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.kafka.common.serialization.Serde<?>getInboundKeySerde(KafkaStreamsConsumerProperties extendedConsumerProperties) Provide theSerdefor inbound key.org.apache.kafka.common.serialization.Serde<?>getInboundKeySerde(KafkaStreamsConsumerProperties extendedConsumerProperties, org.springframework.core.ResolvableType resolvableType) org.apache.kafka.common.serialization.Serde<?>getInboundValueSerde(ConsumerProperties consumerProperties, KafkaStreamsConsumerProperties extendedConsumerProperties) Provide theSerdefor inbound value.org.apache.kafka.common.serialization.Serde<?>getInboundValueSerde(ConsumerProperties consumerProperties, KafkaStreamsConsumerProperties extendedConsumerProperties, org.springframework.core.ResolvableType resolvableType) org.apache.kafka.common.serialization.Serde<?>getOuboundKeySerde(KafkaStreamsProducerProperties properties) Provide theSerdefor outbound key.org.apache.kafka.common.serialization.Serde<?>getOuboundKeySerde(KafkaStreamsProducerProperties properties, org.springframework.core.ResolvableType resolvableType) org.apache.kafka.common.serialization.Serde<?>getOutboundValueSerde(ProducerProperties producerProperties, KafkaStreamsProducerProperties kafkaStreamsProducerProperties) Provide theSerdefor outbound value.org.apache.kafka.common.serialization.Serde<?>getOutboundValueSerde(ProducerProperties producerProperties, KafkaStreamsProducerProperties kafkaStreamsProducerProperties, org.springframework.core.ResolvableType resolvableType) org.apache.kafka.common.serialization.Serde<?>getStateStoreKeySerde(String keySerdeString) Provide theSerdefor state store.org.apache.kafka.common.serialization.Serde<?>getStateStoreValueSerde(String valueSerdeString) Provide theSerdefor state store value.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Method Details
-
getInboundKeySerde
public org.apache.kafka.common.serialization.Serde<?> getInboundKeySerde(KafkaStreamsConsumerProperties extendedConsumerProperties) Provide theSerdefor inbound key.- Parameters:
extendedConsumerProperties- binding level extendedKafkaStreamsConsumerProperties- Returns:
- configurd
Serdefor the inbound key.
-
getInboundKeySerde
public org.apache.kafka.common.serialization.Serde<?> getInboundKeySerde(KafkaStreamsConsumerProperties extendedConsumerProperties, org.springframework.core.ResolvableType resolvableType) -
getInboundValueSerde
public org.apache.kafka.common.serialization.Serde<?> getInboundValueSerde(ConsumerProperties consumerProperties, KafkaStreamsConsumerProperties extendedConsumerProperties) Provide theSerdefor inbound value.- Parameters:
consumerProperties-ConsumerPropertieson bindingextendedConsumerProperties- binding level extendedKafkaStreamsConsumerProperties- Returns:
- configurd
Serdefor the inbound value.
-
getInboundValueSerde
public org.apache.kafka.common.serialization.Serde<?> getInboundValueSerde(ConsumerProperties consumerProperties, KafkaStreamsConsumerProperties extendedConsumerProperties, org.springframework.core.ResolvableType resolvableType) -
getOuboundKeySerde
public org.apache.kafka.common.serialization.Serde<?> getOuboundKeySerde(KafkaStreamsProducerProperties properties) Provide theSerdefor outbound key.- Parameters:
properties- binding level extendedKafkaStreamsProducerProperties- Returns:
- configurd
Serdefor the outbound key.
-
getOuboundKeySerde
public org.apache.kafka.common.serialization.Serde<?> getOuboundKeySerde(KafkaStreamsProducerProperties properties, org.springframework.core.ResolvableType resolvableType) -
getOutboundValueSerde
public org.apache.kafka.common.serialization.Serde<?> getOutboundValueSerde(ProducerProperties producerProperties, KafkaStreamsProducerProperties kafkaStreamsProducerProperties) Provide theSerdefor outbound value.- Parameters:
producerProperties-ProducerPropertieson bindingkafkaStreamsProducerProperties- binding level extendedKafkaStreamsProducerProperties- Returns:
- configurd
Serdefor the outbound value.
-
getOutboundValueSerde
public org.apache.kafka.common.serialization.Serde<?> getOutboundValueSerde(ProducerProperties producerProperties, KafkaStreamsProducerProperties kafkaStreamsProducerProperties, org.springframework.core.ResolvableType resolvableType) -
getStateStoreKeySerde
Provide theSerdefor state store.- Parameters:
keySerdeString- serde class used for key- Returns:
Serdefor the state store key.
-
getStateStoreValueSerde
public org.apache.kafka.common.serialization.Serde<?> getStateStoreValueSerde(String valueSerdeString) Provide theSerdefor state store value.- Parameters:
valueSerdeString- serde class used for value- Returns:
Serdefor the state store value.
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-