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

consumer group per consumer type #GCPActive #317

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@ public class AdminSettings
/// The list of topics the admin client is responsible for ensuring that exist
/// </summary>
public List<string> TopicList { get; set; } = new List<string>();

/// <summary>
/// The retention time in days for the topics
/// </summary>
public int RetentionTime { get; set; } = 7;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected KafkaConsumerBase(

var consumerConfig = new ConsumerConfig(config.ConsumerSettings)
{
GroupId = settings.Value.Consumer.GroupId,
GroupId = $"{settings.Value.Consumer.GroupId}-{GetType().Name.ToLower()}",
EnableAutoCommit = false,
EnableAutoOffsetStore = false,
AutoOffsetReset = AutoOffsetReset.Earliest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ private void EnsureTopicsExist()
{
Name = topic,
NumPartitions = TopicSpecification.NumPartitions,
ReplicationFactor = TopicSpecification.ReplicationFactor
ReplicationFactor = TopicSpecification.ReplicationFactor,
Configs = TopicSpecification.Configs
}
}).Wait();
_logger.LogInformation("// KafkaProducer // EnsureTopicsExists // Topic '{Topic}' created successfully.", topic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ public SharedClientConfig(Configuration.KafkaSettings settings)
consumerConfig.SaslUsername = settings.Consumer.SaslUsername;
consumerConfig.SaslPassword = settings.Consumer.SaslPassword;

string retentionTime = settings.Admin.RetentionTime < 0 ? "-1" : TimeSpan.FromDays(settings.Admin.RetentionTime).TotalMilliseconds.ToString();
topicSpec.NumPartitions = 6;
topicSpec.ReplicationFactor = 3;
topicSpec.Configs = new Dictionary<string, string>()
{
{ "retention.ms", retentionTime },
{ "cleanup.policy", "delete" }
};
}

AdminClientSettings = adminConfig;
Expand Down
Loading