Skip to content

Retry-topics auto creation also creates the main topic #2432

@jgslima

Description

@jgslima

In what version(s) of Spring for Apache Kafka are you seeing this issue?
2.9.1
Actually I already saw this behaviour since 2.8, not sure the oldest version that has this behaviour.

Describe the bug
When the autoCreateTopics feature of the Non-blocking retries main feature is activated, the framework also creates the main topic with the configurations (partitions and replicas) of the retry topics, even if the context has as NewTopic bean for the main topic with different configurations.

To Reproduce

Run the application below:

@SpringBootApplication
@EnableScheduling
@EnableKafkaRetryTopic
@Slf4j
public class SpringKafkaStudies {

	public static void main(String[] args) {
		SpringApplication.run(SpringKafkaStudies.class, args);
	}

	@Bean
	public NewTopic mainTopic() {
		return TopicBuilder
				.name("mytopic")
				.partitions(10)
				.replicas(2)
				.build();
	}

	@RetryableTopic(attempts = "3",
			backoff = @Backoff(delayExpression = "5000"),
			fixedDelayTopicStrategy = FixedDelayStrategy.SINGLE_TOPIC,
			autoCreateTopics = "true",
			numPartitions = "5",
			replicationFactor = "1")
	@KafkaListener(topics = "mytopic", concurrency = "3")
	public void nonBlockingRetriesListen(ConsumerRecord<String, String> record) {
		log.info("Received record: {}", record.value());
	}
	
}

Expected behavior
The main topic "mytopic" to be created with 10 partitions and 2 replicas, and the retry and DLT topic to be created with 5 partitions and 1 replicas.
But actually, the main topic "mytopic" is also created with 5 partitions and 1 replica.

Sample
See the code above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions