简体   繁体   English

在Confluent Python Avro Producer中指定压缩类型

[英]Specify compression type in Confluent Python Avro Producer

Is there a way to specify the compression.type in producer configs while using the AvroProducer in Confluent's Kafka (python)? 在Confluent的Kafka(python)中使用AvroProducer时,是否可以在生产者配置中指定compression.type

I tried the following: 我尝试了以下方法:

from confluent_kafka import avro
from confluent_kafka.avro import AvroProducer

from myconfigs import BOOTSTRAP_SERVER, SCHEMA_REGISTRY_URL, KEY_SCHEMA, VALUE_SCHEMA

avroProducer = AvroProducer({'bootstrap.servers': BOOTSTRAP_SERVER, 'schema.registry.url': SCHEMA_REGISTRY_URL, 'compression.type': 'gzip'},
                            default_key_schema=KEY_SCHEMA, default_value_schema=VALUE_SCHEMA)

Got the following error when running this: 运行此命令时出现以下错误:

Traceback (most recent call last):
  File "confluent_click.py", line 47, in <module>
default_key_schema=KEY_SCHEMA, default_value_schema=VALUE_SCHEMA)
  File "/usr/local/lib/python3.6/site-packages/confluent_kafka/avro/__init__.py", line 38, in __init__
    super(AvroProducer, self).__init__(config)
cimpl.KafkaException: KafkaError{code=_INVALID_ARG,val=-186,str="No such configuration property: "compression.type""}

Also tried specifying compression_type = 'gzip' as a param to AvroProducer() as 还尝试将compression_type = 'gzip'指定为AvroProducer()的参数, AvroProducer()

avroProducer = AvroProducer({'bootstrap.servers': BOOTSTRAP_SERVER, 'schema.registry.url': SCHEMA_REGISTRY_URL},
                            default_key_schema=KEY_SCHEMA, default_value_schema=VALUE_SCHEMA, compression_type='gzip')

I didn't expect this to succeed and it didn't. 我没想到这会成功,但没有成功。

Traceback (most recent call last):
  File "confluent_click.py", line 47, in <module>
    default_key_schema=KEY_SCHEMA, default_value_schema=VALUE_SCHEMA, compression_type='gzip')
TypeError: __init__() got an unexpected keyword argument 'compression_type'

How can I specify compression.type in the producer? 如何在生产者中指定compression.type I have not been able to find AvroProducer 's documentation. 我找不到AvroProducer的文档。

confluent-kafka-python's configuration property for setting the compression type is called compression.codec for historical reasons (librdkafka, which predates the current Java client, based its initial configuration properties on the original Scala client which used compression.codec ). 出于历史原因,confluent-kafka-python的用于设置压缩类型的配置属性称为compression.codec (librdkafka,其早于当前Java客户端,其初始配置属性基于使用compression.codec的原始Scala客户端)。

avroProducer = AvroProducer({'bootstrap.servers': BOOTSTRAP_SERVER, 'schema.registry.url': SCHEMA_REGISTRY_URL, 'compression.codec': 'gzip'},
                            default_key_schema=KEY_SCHEMA, default_value_schema=VALUE_SCHEMA)

Note: the v0.11.4 release of confluent-kafka-python adds a compression.type alias. 注意:confluent-kafka-python v0.11.4版本添加了compression.type别名。

Full list of configuration settings here: https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md 此处的配置设置的完整列表: https : //github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Confluent Python Avro Producer:数据 {&#39;..&#39;} 不是模式的示例 - Confluent Python Avro Producer: The datum {'..'} is not an example of the schema confluent-kafka python avro消息 - confluent-kafka python avro messages Confluent-Kafka:Python使用者中使用模式处理的Avro序列化混淆 - Confluent-Kafka: Avro Serialization Confusions with Schema Handling in Python Consumers confluent-python 可以生成具有 avro 中的值和字符串中的键的数据吗? - can confluent-python produce data with value in avro and key in string? Confluent Kafka Python 生产者不使用 ACKS= 所有配置生产 - Confluent Kafka Python producer not producing with ACKS= all configuration confluent-kafka-python json_producer:无法识别的字段:schemaType - confluent-kafka-python json_producer : Unrecognized field: schemaType Confluent Kafka Python 库为批量 msg 配置生产者 - Confluent Kafka Python library configure producer for bulk msg KafkaError与Confluent Python Kafka使用者不支持的压缩编解码器0x3 - KafkaError Unsupported compression codec 0x3 with Confluent Python Kafka consumer 如何在 zlib 中指定压缩类型? - How do I specify the compression type in zlib? 在Python中为OpenCV视频对象指定压缩质量 - Specify Compression Quality in Python for OpenCV Video Object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM