ProducerOps

io.github.embeddedkafka.ops.ProducerOps

Trait for Producer-related actions.

Type parameters

C

an EmbeddedKafkaConfig

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def publishStringMessageToKafka(topic: String, message: String)(implicit config: C): Unit

Publishes synchronously a message of type String to the running Kafka broker.

Publishes synchronously a message of type String to the running Kafka broker.

Value parameters

config

an implicit EmbeddedKafkaConfig

message

the message to publish

topic

the topic to which publish the message (it will be auto-created)

Attributes

Throws
KafkaUnavailableException

if unable to connect to Kafka

def publishToKafka[T](topic: String, message: T)(implicit config: C, serializer: Serializer[T]): Unit

Publishes synchronously a message to the running Kafka broker.

Publishes synchronously a message to the running Kafka broker.

Value parameters

config

an implicit EmbeddedKafkaConfig

message

the message of type T to publish

serializer

an implicit Serializer for the type T

topic

the topic to which publish the message (it will be auto-created)

Attributes

Throws
KafkaUnavailableException

if unable to connect to Kafka

def publishToKafka[T](producerRecord: ProducerRecord[String, T])(implicit config: C, serializer: Serializer[T]): Unit

Publishes synchronously a message to the running Kafka broker.

Publishes synchronously a message to the running Kafka broker.

Value parameters

config

an implicit EmbeddedKafkaConfig

producerRecord

the producerRecord of type T to publish

serializer

an implicit Serializer for the type T

Attributes

Throws
KafkaUnavailableException

if unable to connect to Kafka

def publishToKafka[K, T](topic: String, key: K, message: T)(implicit config: C, keySerializer: Serializer[K], serializer: Serializer[T]): Unit

Publishes synchronously a message to the running Kafka broker.

Publishes synchronously a message to the running Kafka broker.

Value parameters

config

an implicit EmbeddedKafkaConfig

key

the key of type K to publish

message

the message of type T to publish

serializer

an implicit Serializer for the type T

topic

the topic to which publish the message (it will be auto-created)

Attributes

Throws
KafkaUnavailableException

if unable to connect to Kafka

def publishToKafka[K, T](topic: String, messages: Seq[(K, T)])(implicit config: C, keySerializer: Serializer[K], serializer: Serializer[T]): Unit

Publishes synchronously a batch of message to the running Kafka broker.

Publishes synchronously a batch of message to the running Kafka broker.

Value parameters

config

an implicit EmbeddedKafkaConfig

keySerializer

an implicit Serializer for the type K

messages

the keys and messages of type (K, T) to publish

serializer

an implicit Serializer for the type T

topic

the topic to which publish the message (it will be auto-created)

Attributes

Throws
KafkaUnavailableException

if unable to connect to Kafka

def withProducer[K, V, T](body: (KafkaProducer[K, V]) => T)(implicit config: C, keySerializer: Serializer[K], valueSerializer: Serializer[V]): T

Loaner pattern that allows running a code block with a newly created consumer. The consumer's lifecycle will be automatically handled and closed at the end of the given code block.

Loaner pattern that allows running a code block with a newly created consumer. The consumer's lifecycle will be automatically handled and closed at the end of the given code block.

Value parameters

body

the function to execute that returns T

config

an implicit EmbeddedKafkaConfig

keySerializer

an implicit Serializer for the type K

valueSerializer

an implicit Serializer for the type V

Attributes

Concrete fields

protected val producerPublishTimeout: FiniteDuration