Class/Object

com.github.garyaiki.dendrites.kafka.stream

KafkaSink

Related Docs: object KafkaSink | package stream

Permalink

class KafkaSink[K, V] extends GraphStage[SinkShape[V]]

Sink stage that writes to Kafka

KafkaSink is initialized with a wrapped KafkaProducer. It includes topic, key, Key, Value types for the topic, and retry backoff. KafkaProducer is heavy weight, multi-threaded, may serve other topics and long lived. If a RetryableException is thrown while writing it's retried with backoff If a write throws a Stop Exception the stage fails and the stream is stopped.

KafkaProducer's send returns a Java/Guava ListenableFuture, not a nice Scala Future. The ListenableFuture passes either a RecordMetadata or an Exception to a Callback.

A RecordMetadata is passed on success and an Akka Stream AsynCallback is called that pulls a record from upstream. If an exception was returned a different AsynCallback is called that handles Kafka RetriableExceptions and Stop Exceptions.

RetriableException means the error may not recur, so retry the message. Retries use exponential backoff until success or the configured maxBackoff is reached and then the stream is shutdown.

K

ProducerRecord key

V

Type of serialized object received from stream and ProducerRecord value

Linear Supertypes
GraphStage[SinkShape[V]], GraphStageWithMaterializedValue[SinkShape[V], NotUsed], Graph[SinkShape[V], NotUsed], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. KafkaSink
  2. GraphStage
  3. GraphStageWithMaterializedValue
  4. Graph
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new KafkaSink(prod: ProducerConfig[K, V])(implicit logger: LoggingAdapter)

    Permalink

    sets up Supervision with exponential backoff

    sets up Supervision with exponential backoff

    prod

    extends KafkaProducer with key, value, topic, and backoff fields

    logger

    implicit LoggingAdapter

Type Members

  1. type Shape = SinkShape[V]

    Permalink
    Definition Classes
    Graph

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addAttributes(attr: Attributes): Graph[SinkShape[V], NotUsed]

    Permalink
    Definition Classes
    Graph
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def async: Graph[SinkShape[V], NotUsed]

    Permalink
    Definition Classes
    Graph
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def createLogic(inheritedAttributes: Attributes): GraphStageLogic

    Permalink
    Definition Classes
    KafkaSink → GraphStage
  9. final def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, NotUsed)

    Permalink
    Definition Classes
    GraphStage → GraphStageWithMaterializedValue
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. val in: Inlet[V]

    Permalink
  16. def initialAttributes: Attributes

    Permalink
    Attributes
    protected
    Definition Classes
    GraphStageWithMaterializedValue
  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. final lazy val module: Module

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph
  19. def named(name: String): Graph[SinkShape[V], NotUsed]

    Permalink
    Definition Classes
    Graph
  20. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  21. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. val producer: Producer[K, V]

    Permalink
  24. val shape: SinkShape[V]

    Permalink
    Definition Classes
    KafkaSink → Graph
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def withAttributes(attr: Attributes): Graph[SinkShape[V], NotUsed]

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph

Inherited from GraphStage[SinkShape[V]]

Inherited from GraphStageWithMaterializedValue[SinkShape[V], NotUsed]

Inherited from Graph[SinkShape[V], NotUsed]

Inherited from AnyRef

Inherited from Any

Ungrouped