diff --git a/src/KafkaFlow.Abstractions/Configuration/IClusterConfigurationBuilder.cs b/src/KafkaFlow.Abstractions/Configuration/IClusterConfigurationBuilder.cs
index 494e0d301..2c6968baa 100644
--- a/src/KafkaFlow.Abstractions/Configuration/IClusterConfigurationBuilder.cs
+++ b/src/KafkaFlow.Abstractions/Configuration/IClusterConfigurationBuilder.cs
@@ -75,11 +75,11 @@ public interface IClusterConfigurationBuilder
/// Adds a Topic to the Cluster
///
/// The topic name
- /// The number of Topic partitions
- /// The Topic replication factor
+ /// The number of Topic partitions. Default is to use the cluster-defined partitions.
+ /// The Topic replication factor. Default is to use the cluster-defined replication factor.
///
IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
- int numberOfPartitions,
- short replicationFactor);
+ int numberOfPartitions = -1,
+ short replicationFactor = -1);
}
diff --git a/src/KafkaFlow/Configuration/ClusterConfigurationBuilder.cs b/src/KafkaFlow/Configuration/ClusterConfigurationBuilder.cs
index 6585032b3..cd85129ef 100644
--- a/src/KafkaFlow/Configuration/ClusterConfigurationBuilder.cs
+++ b/src/KafkaFlow/Configuration/ClusterConfigurationBuilder.cs
@@ -110,8 +110,8 @@ public IClusterConfigurationBuilder OnStarted(Action handle
public IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
- int numberOfPartitions,
- short replicationFactor)
+ int numberOfPartitions = -1,
+ short replicationFactor = -1)
{
_topicsToCreateIfNotExist.Add(new TopicConfiguration(topicName, numberOfPartitions, replicationFactor));
return this;
diff --git a/tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs b/tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs
index 272df2b19..5e317cc8e 100644
--- a/tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs
+++ b/tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs
@@ -42,6 +42,7 @@ internal static class Bootstrapper
private const string ProtobufGzipTopicName2 = "test-protobuf-gzip-2";
private const string AvroTopicName = "test-avro";
private const string NullTopicName = "test-null";
+ private const string DefaultParamsTopicName = "test-default-params";
private static readonly Lazy s_lazyProvider = new(SetupProvider);
@@ -202,6 +203,7 @@ private static void SetupServices(HostBuilderContext context, IServiceCollection
.CreateTopicIfNotExists(ProtobufGzipTopicName, 2, 1)
.CreateTopicIfNotExists(ProtobufGzipTopicName2, 2, 1)
.CreateTopicIfNotExists(NullTopicName, 1, 1)
+ .CreateTopicIfNotExists(DefaultParamsTopicName)
.AddConsumer(
consumer => consumer
.Topic(ProtobufTopicName)