Clients
kstreams.ProducerSettings
Kafka producer configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
client_id |
Optional[str]
|
Name passed to Kafka brokers for request logging. Default to None. |
metadata_max_age_ms |
int
|
Interval in milliseconds to force metadata refresh.
Default to 300000 ( |
request_timeout_ms |
int
|
Produce request timeout in milliseconds.
Default to 40000 ( |
acks |
Union[Literal[0, 1], Literal['all']]
|
Required broker acknowledgments for produce requests. Default to 1. |
compression_type |
Optional[Literal['gzip', 'snappy', 'lz4', 'zstd']]
|
Compression algorithm used for produced batches. Default to None |
max_batch_size |
int
|
Maximum buffered bytes per partition before send blocks. Default to 16384 |
partitioner |
Optional[Callable[..., int]]
|
Callable used to choose target partition. Default to None. |
max_request_size |
int
|
Maximum size of a produce request in bytes.
Default to 1048576 ( |
linger_ms |
int
|
Time in milliseconds to wait for additional records before send. Default to 0 |
retry_backoff_ms |
int
|
Backoff in milliseconds between retry attempts. Default to 100 |
connections_max_idle_ms |
Optional[int]
|
Close idle connections after this timeout.
Default to 540000 ( |
enable_idempotence |
bool
|
Enables idempotent production semantics.
The value of |
transactional_id |
Optional[str]
|
Transactional producer id for transactions. Default to None |
transaction_timeout_ms |
int
|
Transaction timeout in milliseconds.
Default to 60000 ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
from kstreams import create_engine
from kstreams.backends.kafka import Kafka
from kstreams.clients import ProducerSettings
backend = Kafka(bootstrap_servers=["localhost:9092"])
producer_settings = ProducerSettings(
client_id="my-producer",
linger_ms=10,
request_timeout_ms=80000,
)
stream_engine = create_engine(
backend=backend,
producer_settings=producer_settings
)
Source code in kstreams/clients.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |