Class AvroDeadLetterConverter

  • All Implemented Interfaces:
    com.bakdata.kafka.DeadLetterConverter<DeadLetter>

    public final class AvroDeadLetterConverter
    extends java.lang.Object
    implements com.bakdata.kafka.DeadLetterConverter<DeadLetter>
    Convert a DeadLetterDescription to an Avro DeadLetter
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <K,​V>
      org.apache.kafka.streams.processor.api.FixedKeyProcessorSupplier<K,​com.bakdata.kafka.ProcessingError<V>,​DeadLetter>
      asProcessor​(java.lang.String description)
      Creates a processor that uses the AvroDeadLetterConverter
      static <V> org.apache.kafka.streams.kstream.ValueTransformerSupplier<com.bakdata.kafka.ProcessingError<V>,​DeadLetter> asTransformer​(java.lang.String description)
      Deprecated.
      DeadLetter convert​(com.bakdata.kafka.DeadLetterDescription deadLetterDescription)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AvroDeadLetterConverter

        public AvroDeadLetterConverter()
    • Method Detail

      • convert

        public DeadLetter convert​(com.bakdata.kafka.DeadLetterDescription deadLetterDescription)
        Specified by:
        convert in interface com.bakdata.kafka.DeadLetterConverter<DeadLetter>
      • asTransformer

        @Deprecated(since="1.4.0")
        public static <V> org.apache.kafka.streams.kstream.ValueTransformerSupplier<com.bakdata.kafka.ProcessingError<V>,​DeadLetter> asTransformer​(java.lang.String description)
        Deprecated.
        Creates a transformer that uses the AvroDeadLetterConverter
        
         // Example, this works for all error capturing topologies
         final KeyValueMapper<K, V, KeyValue<KR, VR>> mapper = ...;
         final KStream<K, V> input = ...;
         final KStream<KR, ProcessedKeyValue<K, V, VR>> processed = input.map(captureErrors(mapper));
         final KStream<KR, VR> output = processed.flatMapValues(ProcessedKeyValue::getValues);
         final KStream<K, ProcessingError<V>> errors = processed.flatMap(ProcessedKeyValue::getErrors);
         final KStream<K, DeadLetter> deadLetters = errors.transformValues(
                              AvroDeadLetterConverter.asTransformer("Description"));
         deadLetters.to(ERROR_TOPIC);
         
         
        Type Parameters:
        V - type of the input value
        Parameters:
        description - shared description for all errors
        Returns:
        a transformer supplier
      • asProcessor

        public static <K,​V> org.apache.kafka.streams.processor.api.FixedKeyProcessorSupplier<K,​com.bakdata.kafka.ProcessingError<V>,​DeadLetter> asProcessor​(java.lang.String description)
        Creates a processor that uses the AvroDeadLetterConverter
        
         // Example, this works for all error capturing topologies
         final KeyValueMapper<K, V, KeyValue<KR, VR>> mapper = ...;
         final KStream<K, V> input = ...;
         final KStream<KR, ProcessedKeyValue<K, V, VR>> processed = input.map(captureErrors(mapper));
         final KStream<KR, VR> output = processed.flatMapValues(ProcessedKeyValue::getValues);
         final KStream<K, ProcessingError<V>> errors = processed.flatMap(ProcessedKeyValue::getErrors);
         final KStream<K, DeadLetter> deadLetters = errors.processValues(
                              AvroDeadLetterConverter.asProcessor("Description"));
         deadLetters.to(ERROR_TOPIC);
         
         
        Type Parameters:
        K - type of the input key
        V - type of the input value
        Parameters:
        description - shared description for all errors
        Returns:
        a processor supplier