Releases: confluentinc/confluent-kafka-python
v1.1.0
Confluent's Python client for Apache Kafka
confluent-kafka-python is based on librdkafka v1.1.0, see the librdkafka v1.1.0 release notes for a complete list of changes, enhancements, fixes and upgrade considerations.
- In-memory SSL certificates (PEM, DER, PKCS#12) support (by @noahdav at Microsoft)
- Use Windows Root/CA SSL Certificate Store (by @noahdav at Microsoft)
ssl.endpoint.identification.algorithm=https
(off by default) to validate the broker hostname matches the certificate. Requires OpenSSL >= 1.0.2(included with Wheel installations))- Improved GSSAPI/Kerberos ticket refresh
- Confluent monitoring interceptor package bumped to v0.11.1 (#634)
Upgrade considerations
- Windows SSL users will no longer need to specify a CA certificate file/directory (
ssl.ca.location
), librdkafka will load the CA certs by default from the Windows Root Certificate Store. - SSL peer (broker) certificate verification is now enabled by default (disable with
enable.ssl.certificate.verification=false
) %{broker.name}
is no longer supported insasl.kerberos.kinit.cmd
since kinit refresh is no longer executed per broker, but per client instance.
SSL
New configuration properties:
ssl.key.pem
- client's private key as a string in PEM formatssl.certificate.pem
- client's public key as a string in PEM formatenable.ssl.certificate.verification
- enable(default)/disable OpenSSL's builtin broker certificate verification.enable.ssl.endpoint.identification.algorithm
- to verify the broker's hostname with its certificate (disabled by default).- Add new
rd_kafka_conf_set_ssl_cert()
to pass PKCS#12, DER or PEM certs in (binary) memory form to the configuration object. - The private key data is now securely cleared from memory after last use.
Enhancements
- Bump
message.timeout.ms
max value from 15 minutes to 24 days (@sarkanyi, workaround for #2015)
Fixes
- SASL GSSAPI/Kerberos: Don't run kinit refresh for each broker, just per client instance.
- SASL GSSAPI/Kerberos: Changed
sasl.kerberos.kinit.cmd
to first attempt ticket refresh, then acquire. - SASL: Proper locking on broker name acquisition.
- Consumer:
max.poll.interval.ms
now correctly handles blocking poll calls, allowing a longer poll timeout than the max poll interval. - configure: Fix libzstd static lib detection
- PyTest pinned to latest version supporting python 2 (#634)
Version 1.0.1
Confluent's Python client for Apache Kafka
confluent-kafka-python is based on librdkafka v1.0.1, see the librdkafka v1.0.1 release notes for a complete list of changes, enhancements, fixes and upgrade considerations.
v1.0.1 is a maintenance release with the following fixes:
- Fix consumer stall when broker connection goes down (issue #2266 introduced in v1.0.0)
- Fix AdminAPI memory leak when broker does not support request (@souradeep100, #2314)
- SR client: Don't disable cert verification if no ssl.ca.location set (#578)
- Treat ECONNRESET as standard Disconnects (#2291)
- OpenSSL version bump to 1.0.2s
- Update/fix protocol error response codes (@benesch)
- Update Consumer get_watermark_offsets docstring (@hrchu, #572)
- Update Consumer subscribe docstring to include on_assign and on_revoke args (@hrchu, #571)
- Update delivery report string formatting (@hrchu, #575)
- Update logging configuration code example document (@soxofaan , #579)
- Implement environment markers to fix poetry (@fishman, #583)
v1.0.0
Confluent's Python client for Apache Kafka v1.0.0
confluent-kafka-python is based on librdkafka v1.0.0, see the librdkafka v1.0.0 release notes for a complete list of changes, enhancements and fixes and upgrade considerations.
v1.0.0 is a major feature release:
- Idempotent producer - guaranteed ordering, exactly-once producing) support.
- Sparse/on-demand connections - connections are no longer maintained to all brokers in the cluster.
- KIP-62 -
max.poll.interval.ms
support in the Consumer.
This release also changes configuration defaults and deprecates a set
of configuration properties, make sure to read the Upgrade considerations
section below.
Upgrade considerations (IMPORTANT)
Configuration default changes
The following configuration properties have changed default values, which
may require application changes:
-
acks
(aliasrequest.required.acks
) now defaults toall
; wait for all in-sync replica brokers to ack. The previous default,1
, only waited for an ack from the partition leader. This change places a greater emphasis on durability at a slight cost to latency. It is not recommended that you lower this value unless latency takes a higher precedence than data durability in your application. -
broker.version.fallback
now to defaults to0.10
, previously0.9
.broker.version.fallback.ms
now defaults to 0. Users on Apache Kafka <0.10 must setapi.version.request=false
andbroker.version.fallback=..
to their broker version. For users >=0.10 there is no longer any need to specify any of these properties. -
enable.partition.eof
now defaults tofalse
.KafkaError._PARTITION_EOF
was previously emitted by default to signify the consumer has reached the end of a partition. Applications which rely on this behavior must now explicitly setenable.partition.eof=true
if this behavior is required. This change simplifies the more common case where consumer applications consume in an endless loop.
group.id
is now required for Python consumers.
Deprecated configuration properties
The following configuration properties have been deprecated. Use of any deprecated configuration property will result in a warning when the client instance is created. The deprecated configuration properties will be removed in a future release.
librdkafka:
offset.store.method=file
is deprecated.offset.store.path
is deprecated.offset.store.sync.interval.ms
is deprecated.produce.offset.report
is no longer used. Offsets are always reported.queuing.strategy
was an experimental property that is now deprecated.reconnect.backoff.jitter.ms
is no longer used, seereconnect.backoff.ms
andreconnect.backoff.max.ms
.socket.blocking.max.ms
is no longer used.topic.metadata.refresh.fast.cnt
is no longer used.
confluent_kafka:
default.topic.config
is deprecated.- `CachedSchemaRegistryClient: url: was str, now conf dict with all application config properties
Idempotent Producer
This release adds support for Idempotent Producer, providing exactly-once
producing and guaranteed ordering of messages.
Enabling idempotence is as simple as setting the enable.idempotence
configuration property to true
.
There are no required application changes, but it is recommended to add
support for the newly introduced fatal errors that will be triggered when the idempotent producer encounters an unrecoverable error that would break the ordering or duplication guarantees.
See Idempotent Producer in the manual and the Exactly once semantics blog post for more information.
Sparse connections
In previous releases librdkafka would maintain open connections to all
brokers in the cluster and the bootstrap servers.
With this release librdkafka now connects to a single bootstrap server
to retrieve the full broker list, and then connects to the brokers
it needs to communicate with: partition leaders, group coordinators, etc.
For large scale deployments this greatly reduces the number of connections
between clients and brokers, and avoids the repeated idle connection closes
for unused connections.
Sparse connections is on by default (recommended setting), the old
behavior of connecting to all brokers in the cluster can be re-enabled
by setting enable.sparse.connections=false
.
See Sparse connections in the manual for more information.
Original issue librdkafka #825.
KIP-62 - max.poll.interval.ms
is enforced
This release adds support for max.poll.interval.ms
(KIP-62), which requires
the application to call consumer.poll()
at least every max.poll.interval.ms
.
Failure to do so will make the consumer automatically leave the group, causing a group rebalance,
and not rejoin the group until the application has called ..poll() again, triggering yet another group rebalance.
max.poll.interval.ms
is set to 5 minutes by default.
Enhancements
- OpenSSL version bumped to 1.0.2r
- AvroProducer now supports encoding with fastavro (#492)
- Simplify
CachedSchemaRegistryClient
configuration with configuration dict for application configs - Add
Delete Schema
support to CachedSchemaRegistryClient - CachedSchemaRegistryClient now supports HTTP Basic Auth (#440)
- MessageSerializer now supports specifying reader schema (#470)
Fixes
- Fix crash when calling
Consumer.consume
without settinggroup.id
(now required) CachedSchemaRegistryClient
handlesget_compatibility
properly
Build/installation/tooling
- Integration tests moved to docker-compose to aid in cluster set-up/tear-down
- Runner script
./tests/run.sh
added to simplify unit and integration test execution
v0.11.6
See librdkafka v0.11.6 release notes for enhancements and fixes in librdkafka.
New Features
- Confluent Monitoring Interceptors are now included with Linux and OSX binary wheel distributions. (#464)
- Experimental binary wheel distributions for Windows environments. (#451)
Enhancements
- OpenSSL version bump to 1.0.2p. (#437)
- Topic configurations have been moved into the global configuration dictionary to simplify configuration. The property
default.topic.configuration
has been deprecated and will be removed in 1.0, but still has precedence to topic configuration specified in the global configuration dictionary. (#446)
Fixes
v0.11.5
Admin Client support
v0.11.5 is a feature release that adds support for the Kafka Admin API (KIP-4).
Admin API
This release adds support for the Admin API, enabling applications and users to perform administrative Kafka tasks programmatically:
- Create topics - specifying partition count, replication factor and topic configuration.
- Delete topics - delete topics in cluster.
- Create partitions - extend a topic with additional partitions.
- Alter configuration - set, modify or delete configuration for any Kafka resource (topic, broker, ..).
- Describe configuration - view configuration for any Kafka resource.
The API closely follows the Java Admin API:
def example_create_topics(a, topics):
new_topics = [NewTopic(topic, num_partitions=3, replication_factor=1) for topic in topics]
# Call create_topics to asynchronously create topics
fs = a.create_topics(new_topics)
# Wait for operation to finish.
for topic, f in fs.items():
try:
f.result() # The result itself is None
print("Topic {} created".format(topic))
except Exception as e:
print("Failed to create topic {}: {}".format(topic, e))
Additional examples can be found in examples/adminapi
Enhancements
- Schema Registry HTTPS support with TLS client auth added (#90)
- Metadata API list_topics() added (#161, @tbsaunde, @stephan-hof)
- Expose librdkafka built-in partitioner options directly (#396)
- Callback based throttle event handling;
throttle_cb
(#237) (#377) - Added Unicode support for header values (#382)
- OpenSSL version bump to 1.0.2o (#410)
- Avro documentation added to the docs (#382)
- Python 3.7 support (#382)
- Allow passing headers as both list(tuples) and dict() (#355)
- Support for legacy setuptool's install_requires (#399)
Fixes
- Release GIL before making blocking calls (#412)
- Prevent application config dict mutation (#412)
- Intercept plugin configurations to ensure proper ordering (#404)
test_compatibility()
should returnFalse
notNone
would returnNone
when unable to check compatibility (#372, @Enether)- Schema Registry client returns false when unable to check compatibility(#372, @Enether)
- Fix invocation of SchemaParseException (#376)
- Fix call ordering to avoid callback crash on implicit close (#265)
- Fix memory leaks in generic client setters (#382)
- Fix AvroProducer/AvroConsumer key/value identity check (#342)
- Correct
Producer.produce
documentation to use correct time unit of seconds (#384) (#385) - Fix KafkaError refcounting which could lead to memory leaks (#382)
v0.11.4
Simplified installation
This release adds binary wheels containing all required dependencies (librdkafka, openssl, zlib, etc) for Linux and OSX.
Should these wheels not work on your platform then please file an issue outlining what is failing, and then use the previous method of installing librdkafka manually followed by pip install --no-binary all confluent-kafka
Message header support
Support for Kafka message headers has been added (requires broker version >= v0.11.0).
When producing messages simply provide a list of key,value tuples as headers=
:
myproducer.produce(topic, 'A message payload', headers=[('hdr1', 'val1'), ('another', 'one'), ('hdr1', 'duplicates are supported and ordering is retained')])
Message headers are returned as a list of tuples for consumed messages:
msg = myconsumer.poll(1)
if msg is not None and not msg.error():
headers = msg.headers()
if headers is not None:
# convert to dict, collapsing duplicate header keys
headers_dict = dict(headers)
Enhancements
- Message header support (@johnistan)
- Added Consumer.seek()
- Added consumer.pause/resume support (closes #120, @dangra)
- Added Consumer.store_offsets() API (#245, @ctrochalakis)
- Support for passing librdkafka logs to the standard logging module (see
logger
kwarg in constructors) (#148) - Enable produce.offset.report by default (#266) (#267)
- Expose offsets_for_times consumer method. closes #224 (#268, @johnistan)
- Add batch consume() API (closes #252, #282, @tburmeister)
- Add hash func for UnionSchema (#228, @fyndiq)
- Use schemaless reader to handle complex schema (#251, @fpietka)
Fixes
- Fix librdkafka install command for macOS (#281, @vkroz)
- Constructors now support both dict and kwargs
- Add
__version__
to__init__.py
(@mrocklin) - Messages could be leaked&lost if exception raised from callback triggered by poll()
- Make Consumer.commit(..,asynchronous=False) return offset commit results
- Raise runtime error if accessing consumer after consumer close (#262, @johnistan)
- Pass py.test arguments from tox (@ctrochalakis)
- Rename
async
kwargs toasynchronous
(async
will continue working until the 1.0 API bump)
v0.11.0
This is a minimal librdkafka version-synchronized release of the Python client.
Changes:
- Handle null/None values during deserialization
- Allow to pass custom schema registry instance.
- None conf values are now converted to NULL rather than the string "None" (#133)
- Fix memory leaks when certain exceptions were raised.
- Handle delivery.report.only.error in Python (#84)
- Proper use of Message error string on Producer (#129)
- Now Flake8 clean