Skip to content

Producer automatic topic creation is disabled when there are multiple topics #3058

Open
@sonalys

Description

Description

When using the producer with: allowAutoTopicCreation = true, the func tryRefreshMetadata on file client.go is behaving strangely:

allowAutoTopicCreation := client.conf.Metadata.AllowAutoTopicCreation
if len(topics) > 0 {
	DebugLogger.Printf("client/metadata fetching metadata for %v from broker %s\n", topics, broker.addr)
} else {
	allowAutoTopicCreation = false
	DebugLogger.Printf("client/metadata fetching metadata for all topics from broker %s\n", broker.addr)
}

req := NewMetadataRequest(client.conf.Version, topics)
req.AllowAutoTopicCreation = allowAutoTopicCreation

This behavior reproduces for both sync and async producers. So if you are asynchronously sending messages to different topics, they won't respect the allowAutoTopicCreation configuration.

I don't know if this is a technical limitation or not, but this behavior is totally hidden from the developer.

Versions

github.com/IBM/sarama v1.44.0

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions