public class SenderOptions<K,V> extends Object
KafkaSender and its underlying Kafka
Producer.| Modifier and Type | Method and Description |
|---|---|
Duration |
closeTimeout()
Returns the timeout for graceful shutdown of this sender.
|
SenderOptions<K,V> |
closeTimeout(Duration timeout)
Configures the timeout for graceful shutdown of this sender.
|
static <K,V> SenderOptions<K,V> |
create()
Creates a sender options instance with default properties.
|
static <K,V> SenderOptions<K,V> |
create(Map<String,Object> configProperties)
Creates a sender options instance with the specified config overrides for the underlying
Kafka
Producer. |
static <K,V> SenderOptions<K,V> |
create(Properties configProperties)
Creates a sender options instance with the specified config overrides for the underlying
Kafka
Producer. |
boolean |
fatalException(Throwable t) |
boolean |
isTransactional()
Senders created from this options will be transactional if a transactional id is
configured using
ProducerConfig.TRANSACTIONAL_ID_CONFIG. |
int |
maxInFlight()
Returns the maximum number of in-flight records that are fetched
from the outbound record publisher while acknowledgements are pending.
|
SenderOptions<K,V> |
maxInFlight(int maxInFlight)
Configures the maximum number of in-flight records that are fetched
from the outbound record publisher while acknowledgements are pending.
|
Map<String,Object> |
producerProperties()
Returns the configuration properties for the underlying Kafka
Producer. |
Object |
producerProperty(String name)
Returns the Kafka
Producer configuration property value for the specified option name. |
SenderOptions<K,V> |
producerProperty(String name,
Object value)
Sets Kafka
Producer configuration property to the specified value. |
Scheduler |
scheduler()
Returns the scheduler used for publishing send results.
|
SenderOptions<K,V> |
scheduler(Scheduler scheduler)
Sets the scheduler used for publishing send results.
|
boolean |
stopOnError()
Returns stopOnError configuration which indicates if a send operation
should be terminated when an error is encountered.
|
SenderOptions<K,V> |
stopOnError(boolean stopOnError)
Configures error handling behaviour for
KafkaSender.send(org.reactivestreams.Publisher). |
SenderOptions<K,V> |
toImmutable()
Returns a new immutable instance with the configuration properties of this instance.
|
String |
transactionalId()
Returns the configured transactional id
|
public static <K,V> SenderOptions<K,V> create()
public static <K,V> SenderOptions<K,V> create(Map<String,Object> configProperties)
Producer.public static <K,V> SenderOptions<K,V> create(Properties configProperties)
Producer.public Map<String,Object> producerProperties()
Producer.public Object producerProperty(String name)
Producer configuration property value for the specified option name.public SenderOptions<K,V> producerProperty(String name, Object value)
Producer configuration property to the specified value.public Scheduler scheduler()
public SenderOptions<K,V> scheduler(Scheduler scheduler)
public int maxInFlight()
public SenderOptions<K,V> maxInFlight(int maxInFlight)
ProducerConfig.BUFFER_MEMORY_CONFIG
to control memory usage and to avoid blocking the reactive pipeline.public boolean stopOnError()
public SenderOptions<K,V> stopOnError(boolean stopOnError)
KafkaSender.send(org.reactivestreams.Publisher).
If set to true, send fails when an error is encountered and only records
that are already in transit may be delivered after the first error. If set to false,
an attempt is made to send each record to Kafka, even if one or more records cannot
be delivered after the configured number of retries due to a non-fatal exception.
This flag should be set along with ProducerConfig.RETRIES_CONFIG and
ProducerConfig.ACKS_CONFIG to configure the required quality-of-service.
By default, stopOnError is true.stopOnError - true to stop each send sequence on first failurepublic Duration closeTimeout()
public SenderOptions<K,V> closeTimeout(Duration timeout)
public boolean isTransactional()
ProducerConfig.TRANSACTIONAL_ID_CONFIG. If transactional,
KafkaProducer.initTransactions() is invoked on the producer to initialize
transactions before any operations are performed on the sender. If scheduler is overridden
using scheduler(reactor.core.scheduler.Scheduler), the configured scheduler
must be single-threaded. Otherwise, the behaviour is undefined and may result in unexpected
exceptions.public String transactionalId()
public boolean fatalException(Throwable t)
public SenderOptions<K,V> toImmutable()