Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a way to specify properties like retention.ms which must be Long and not a String #3667

Open
johnament opened this issue Dec 13, 2024 · 1 comment

Comments

@johnament
Copy link

In what version(s) of Spring for Apache Kafka are you seeing this issue?

2.8.2 and Prior

Describe the bug

When attempting to use NewTopic to configure properties like retention.ms, the API currently only allows those properties to be strings:

    return TopicBuilder.name(topicName)
        .partitions(partitions)
        .configs(
            Map.of(TOPIC_RETENTION_MS, retentionMs)) // map here is String, String
        .build();

However, retention.ms is a Long type and Kafka will error out when trying to set it this way:

org.apache.kafka.common.errors.InvalidConfigurationException: Invalid value '86400000' for configuration retention.ms: Not a number of type LONG

(I was trying to set it to 1 day retention)

To Reproduce

Steps to reproduce the behavior.

  • Configure topic as above

Expected behavior

  • Either the data type is inferred by the property, or there's a way to accept a Map<String, Object> for data types.
@artembilan
Copy link
Member

The TopicBuilder in the end delegates to org.apache.kafka.clients.admin.NewTopic:

topic.configs(this.configs);

and that one is like this:

    /**
     * Set the configuration to use on the new topic.
     *
     * @param configs               The configuration map.
     * @return                      This NewTopic object.
     */
    public NewTopic configs(Map<String, String> configs) {

So, nothing what we can do here in Spring until Apache Kafka client solves that for all of us.
Please, consider to raise this concern against Apache Kafka itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants