You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Mathias Kub (JIRA)" <ji...@apache.org> on 2017/02/06 13:22:42 UTC

[jira] [Commented] (KAFKA-4715) Consumer/Producer config does not work with related enums

    [ https://issues.apache.org/jira/browse/KAFKA-4715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15853975#comment-15853975 ] 

Mathias Kub commented on KAFKA-4715:
------------------------------------

Hi, I've introduced a small changeset to include a {{configValue}} property in the enums to enable the access to the configuration values, like

{code}
properties.setProperty(ProducerConfig.COMPRESSION_TYPE_CONFIG, CompressionType.SNAPPY.configValue);
{code}

instead of

{code}
properties.setProperty(ProducerConfig.COMPRESSION_TYPE_CONFIG, CompressionType.SNAPPY.name());
{code}

Of course you could introduce the case-insensitivity as well or think about passing a {{KafkaProducerConfig}} with typed values instead of a {{Properties}} instance.

Please have a look at https://github.com/apache/kafka/compare/trunk...makubi:KAFKA-4715-enum-config-values?expand=1. If you are OK with it, I would submit a PR.

> Consumer/Producer config does not work with related enums
> ---------------------------------------------------------
>
>                 Key: KAFKA-4715
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4715
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: Bryan Baugher
>            Priority: Minor
>
> We have some code that builds producer/consumer config and sometimes uses the related enum like this,
> {code}
> Properties properties = new Properties();
> properties.setProperty(ProducerConfig.COMPRESSION_TYPE_CONFIG, CompressionType.SNAPPY.name());
> ...
> Producer producer = new KafkaProducer(properties);
> {code}
> We get,
> {code}
> org.apache.kafka.common.KafkaException: Failed to construct kafka producer
> ...
> Caused by: java.lang.IllegalArgumentException: Unknown compression name: SNAPPY
> {code}
> We've seen the same for others like ConsumerConfig.AUTO_OFFSET_RESET_CONFIG and its OffsetResetStrategy enum.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)