ProducerSettings

zio.kafka.producer.ProducerSettings
See theProducerSettings companion object
final case class ProducerSettings(closeTimeout: Duration, sendBufferSize: Int, authErrorRetrySchedule: Schedule[Any, Throwable, Any], properties: Map[String, AnyRef])

Settings for the Producer.

To stay source compatible with future releases, you are recommended to construct the settings as follows:

 ProducerSettings(bootstrapServers)
   .withLinger(500.millis)
   .withCompression(ProducerCompression.Zstd(3))
   .... etc.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def driverSettings: Map[String, AnyRef]
def withAuthErrorRetrySchedule(authErrorRetrySchedule: Schedule[Any, Throwable, Any]): ProducerSettings

Value parameters

authErrorRetrySchedule

The schedule at which the producer will retry producing, even when producing fails with an org.apache.kafka.common.errors.AuthorizationException or org.apache.kafka.common.errors.AuthenticationException. This setting helps with failed producing due to too slow authorization or authentication in the broker. For example, to retry 5 times, spaced by 500ms, you can set this to

Schedule.recurs(5) && Schedule.spaced(500.millis)

The default is Schedule.stop which is, to fail the producer on the first auth error. ⚠️ Retrying can cause records to be produced in a different order than the order in which they were given to zio-kafka.

Attributes

Value parameters

compression

The compression codec to use when publishing records. Compression is of full batches of data, so the efficacy of batching will also impact the compression ratio (more batching means better compression). See also withLinger.

Attributes

def withLinger(lingerDuration: Duration): ProducerSettings

Value parameters

lingerDuration

The maximum amount of time a record is allowed to linger in the producer's internal buffer. Higher values allow for better batching (especially important when compression is used), lower values reduce latency and memory usage.

Attributes

def withProperties(kvs: (String, AnyRef)*): ProducerSettings
def withProperty(key: String, value: AnyRef): ProducerSettings
def withSendBufferSize(sendBufferSize: Int): ProducerSettings

Value parameters

sendBufferSize

The maximum number of record chunks that can queue up while waiting for the underlying producer to become available.

Attributes

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product