ProducerSettings

sealed abstract class ProducerSettings[F[_], K, V]

ProducerSettings contain settings necessary to create a KafkaProducer. At the very least, this includes a key serializer and a value serializer.

Several convenience functions are provided so that you don't have to work with String values and ProducerConfig for configuration. It's still possible to specify ProducerConfig values with functions like withProperty.

ProducerSettings instances are immutable and all modification functions return a new ProducerSettings instance.

Use ProducerSettings#apply to create a new instance.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def closeTimeout: FiniteDuration

The time to wait for the Java KafkaProducer to shutdown.

The default value is 60 seconds.

The time to wait for the Java KafkaProducer to shutdown.

The default value is 60 seconds.

def customBlockingContext: Option[ExecutionContext]

A custom ExecutionContext to use for blocking Kafka operations. If not provided, the default blocking ExecutionContext provided by cats.effect.Sync will be used.

A custom ExecutionContext to use for blocking Kafka operations. If not provided, the default blocking ExecutionContext provided by cats.effect.Sync will be used.

The Serializer to use for serializing record keys.

The Serializer to use for serializing record keys.

def parallelism: Int

The maximum number of ProducerRecords to produce in the same batch.

The default value is 10000.

The maximum number of ProducerRecords to produce in the same batch.

The default value is 10000.

def properties: Map[String, String]

Properties which can be provided when creating a Java KafkaProducer instance. Numerous functions in ProducerSettings add properties here if the settings are used by the Java KafkaProducer.

Properties which can be provided when creating a Java KafkaProducer instance. Numerous functions in ProducerSettings add properties here if the settings are used by the Java KafkaProducer.

The Serializer to use for serializing record values.

The Serializer to use for serializing record values.

def withAcks(acks: Acks): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified acknowledgements. This is equivalent to setting the following property using the withProperty function, except you can specify it with Acks instead of a String.

Returns a new ProducerSettings instance with the specified acknowledgements. This is equivalent to setting the following property using the withProperty function, except you can specify it with Acks instead of a String.

ProducerConfig.ACKS_CONFIG
def withBatchSize(batchSize: Int): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified batch size. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

Returns a new ProducerSettings instance with the specified batch size. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

ProducerConfig.BATCH_SIZE_CONFIG
def withBootstrapServers(bootstrapServers: String): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified bootstrap servers. This is equivalent to setting the following property using the withProperty function.

Returns a new ProducerSettings instance with the specified bootstrap servers. This is equivalent to setting the following property using the withProperty function.

ProducerConfig.BOOTSTRAP_SERVERS_CONFIG
def withClientId(clientId: String): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified client id. This is equivalent to setting the following property using the withProperty function.

Returns a new ProducerSettings instance with the specified client id. This is equivalent to setting the following property using the withProperty function.

ProducerConfig.CLIENT_ID_CONFIG
def withCloseTimeout(closeTimeout: FiniteDuration): ProducerSettings[F, K, V]

Creates a new ProducerSettings with the specified closeTimeout.

Creates a new ProducerSettings with the specified closeTimeout.

def withCredentials(credentialsStore: KafkaCredentialStore): ProducerSettings[F, K, V]

Includes the credentials properties from the provided KafkaCredentialStore

Includes the credentials properties from the provided KafkaCredentialStore

def withCustomBlockingContext(ec: ExecutionContext): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified ExecutionContext to use for blocking operations.

Returns a new ProducerSettings instance with the specified ExecutionContext to use for blocking operations.

If not provided, the default blocking ExecutionContext provided by cats.effect.Sync will be used. If in doubt, leave this unset.

def withDeliveryTimeout(deliveryTimeout: FiniteDuration): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified delivery timeout. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

Returns a new ProducerSettings instance with the specified delivery timeout. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG
def withEnableIdempotence(enableIdempotence: Boolean): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified idempotence setting. This is equivalent to setting the following property using the withProperty function, except you can specify it with a Boolean instead of a String.

Returns a new ProducerSettings instance with the specified idempotence setting. This is equivalent to setting the following property using the withProperty function, except you can specify it with a Boolean instead of a String.

ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG
def withLinger(linger: FiniteDuration): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified linger. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

Returns a new ProducerSettings instance with the specified linger. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

ProducerConfig.LINGER_MS_CONFIG
def withMaxInFlightRequestsPerConnection(maxInFlightRequestsPerConnection: Int): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified max in-flight requests per connection. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

Returns a new ProducerSettings instance with the specified max in-flight requests per connection. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION
def withParallelism(parallelism: Int): ProducerSettings[F, K, V]

Creates a new ProducerSettings with the specified parallelism.

Creates a new ProducerSettings with the specified parallelism.

def withProperties(properties: (String, String)*): ProducerSettings[F, K, V]

Includes the specified keys and values as properties. The keys should be part of the ProducerConfig keys, and the values should be valid choices for the keys.

Includes the specified keys and values as properties. The keys should be part of the ProducerConfig keys, and the values should be valid choices for the keys.

def withProperties(properties: Map[String, String]): ProducerSettings[F, K, V]

Includes the specified keys and values as properties. The keys should be part of the ProducerConfig keys, and the values should be valid choices for the keys.

Includes the specified keys and values as properties. The keys should be part of the ProducerConfig keys, and the values should be valid choices for the keys.

def withProperty(key: String, value: String): ProducerSettings[F, K, V]

Includes a property with the specified key and value. The key should be one of the keys in ProducerConfig, and the value should be a valid choice for the key.

Includes a property with the specified key and value. The key should be one of the keys in ProducerConfig, and the value should be a valid choice for the key.

def withRequestTimeout(requestTimeout: FiniteDuration): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified request timeout. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

Returns a new ProducerSettings instance with the specified request timeout. This is equivalent to setting the following property using the withProperty function, except you can specify it with a FiniteDuration instead of a String.

ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG
def withRetries(retries: Int): ProducerSettings[F, K, V]

Returns a new ProducerSettings instance with the specified retries. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

Returns a new ProducerSettings instance with the specified retries. This is equivalent to setting the following property using the withProperty function, except you can specify it with an Int instead of a String.

ProducerConfig.RETRIES_CONFIG