Reputation: 85
I am creating topic dynamically in spring boot on my local machine.But when described the the topic there was only one partition. Below is the code.
@Bean
public NewTopic newTopic() {
return new NewTopic("kafkaTopic",20,(short)2);
//return TopicBuilder.name("kafkaTopic").partitions(15).replicas(2).build();// tried with as well.
}
o/p:-
Topic: kafkaTopic TopicId: ZiypKK48Q0GqcNwsx6323Q PartitionCount: 1 ReplicationFactor: Configs:
Topic: kafkaTopic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Looked through net but not able to resolve issue.
Config code
@Bean
public ProducerFactory<String, String> producerFactoryString() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, server);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
return new DefaultKafkaProducerFactory<>(configProps);
}
@Bean
public ConsumerFactory<String, String> consumerFactory() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, server);
configProps.put(ConsumerConfig.GROUP_ID_CONFIG, consumerGroupId);
configProps.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
configProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
configProps.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, "200");
configProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
configProps.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, "550000");
configProps.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
configProps.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "55000");
configProps.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, "25000");
return new DefaultKafkaConsumerFactory<>(configProps);
}
Did i miss any configuration or anything to add?
Upvotes: 3
Views: 490
Reputation: 192013
As shown by the CLI describe output, you only have one broker. Therefore, you are limited to one replica, rather than 2.
Upvotes: 1