From d6e68f8f1a75a6c2d60c8911e4864c4dd1df426e Mon Sep 17 00:00:00 2001 From: "elif.bayrakdar" Date: Fri, 9 Feb 2024 08:11:20 +0300 Subject: [PATCH 1/2] #36 Add Acks to ProducerConfig if exists in configuration as ProducerAcks --- .github/workflows/publish.yml | 2 +- .gitlab-ci.yml | 2 +- CHANGELOG.MD | 11 +++++++++++ src/Helpers/Constants.cs | 3 --- src/Services/Implementations/ConfigurationService.cs | 2 +- src/Services/Implementations/KafkaService.cs | 9 +++++++-- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c0352bd..76df587 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,7 +19,7 @@ jobs: name: Build & push Docker image with: image: kafka-retry-job - tags: 1.12.0, latest + tags: 1.12.1, latest registry: ghcr.io username: ${{ secrets.GHCR_USERNAME }} password: ${{ secrets.GHCR_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8964bfa..a166a27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: - VERSION: "1.12.0" + VERSION: "1.12.1" DOCKER_IMAGE_VERSION: $GITLAB_REGISTRY_HOST/$CI_PROJECT_PATH:$VERSION DOCKER_IMAGE_LATEST: $GITLAB_REGISTRY_HOST/$CI_PROJECT_PATH diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 42ac1e3..010f2cd 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,16 @@ # Changelog +## [1.12.1](https://github.com/github-changelog-generator/github-changelog-generator/tree/1.16.4) (2024-02) + +**Closed issues:** + +- [\#36](https://github.com/Trendyol/kafka-retry-job/issues/36) Add Acks to ProducerConfig if exists in configuration as ProducerAcks + +**Merged pull requests:** + +- Pull Request for the issues #36 [\#36](https://github.com/Trendyol/kafka-retry-job/pull/36) ([elifbayrakdar](https://github.com/elifbayrakdar)) + + ## [1.12.0](https://github.com/github-changelog-generator/github-changelog-generator/tree/1.16.4) (2024-01) **Closed issues:** diff --git a/src/Helpers/Constants.cs b/src/Helpers/Constants.cs index 4c3fa97..916132a 100644 --- a/src/Helpers/Constants.cs +++ b/src/Helpers/Constants.cs @@ -1,5 +1,3 @@ -using Confluent.Kafka; - namespace KafkaRetry.Job.Helpers; public static class Constants @@ -7,7 +5,6 @@ public static class Constants public static class ProducerConfigDefaults { public const bool EnableIdempotence = true; - public const Acks Acks = Confluent.Kafka.Acks.Leader; public const int BatchSize = 1000000; public const string ClientId = "rdkafka"; public const double LingerMs = 5; diff --git a/src/Services/Implementations/ConfigurationService.cs b/src/Services/Implementations/ConfigurationService.cs index 17de3cf..4ddeaf7 100644 --- a/src/Services/Implementations/ConfigurationService.cs +++ b/src/Services/Implementations/ConfigurationService.cs @@ -37,7 +37,7 @@ public ConfigurationService(IConfiguration configuration) public bool EnableIdempotence => GetValue("ProducerEnableIdempotence") ?? Constants.ProducerConfigDefaults.EnableIdempotence; - public Acks? Acks => GetValue("ProducerAcks") ?? Constants.ProducerConfigDefaults.Acks; + public Acks? Acks => GetValue("ProducerAcks"); public int BatchSize => GetValue("ProducerBatchSize") ?? Constants.ProducerConfigDefaults.BatchSize; diff --git a/src/Services/Implementations/KafkaService.cs b/src/Services/Implementations/KafkaService.cs index 59d1f8c..67df77c 100644 --- a/src/Services/Implementations/KafkaService.cs +++ b/src/Services/Implementations/KafkaService.cs @@ -57,7 +57,7 @@ private AdminClientConfig CreateAdminClientConfig(string bootstrapServers) private ProducerConfig CreateProducerConfig(string bootstrapServers) { - return new ProducerConfig + var producerConfig = new ProducerConfig { BootstrapServers = bootstrapServers, SaslUsername = _configuration.SaslUsername ?? string.Empty, @@ -67,7 +67,6 @@ private ProducerConfig CreateProducerConfig(string bootstrapServers) SecurityProtocol = _configuration.SecurityProtocol, SslKeystorePassword = _configuration.SslKeystorePassword ?? string.Empty, EnableIdempotence = _configuration.EnableIdempotence, - Acks = _configuration.Acks, BatchSize = _configuration.BatchSize, ClientId = _configuration.ClientId, LingerMs = _configuration.LingerMs, @@ -75,6 +74,12 @@ private ProducerConfig CreateProducerConfig(string bootstrapServers) RequestTimeoutMs = _configuration.RequestTimeoutMs, MessageMaxBytes = _configuration.MessageMaxBytes }; + + if (_configuration.Acks is not null) + { + producerConfig.Acks = _configuration.Acks; + } + return producerConfig; } private ConsumerConfig CreateConsumerConfig(string bootstrapServers, string groupId) From affca855b1f094324892cff0c4cfa3d61e6f8aef Mon Sep 17 00:00:00 2001 From: "elif.bayrakdar" Date: Fri, 9 Feb 2024 08:17:16 +0300 Subject: [PATCH 2/2] #36 Edit CHANGELOG.MD --- CHANGELOG.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 010f2cd..8504857 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -8,7 +8,7 @@ **Merged pull requests:** -- Pull Request for the issues #36 [\#36](https://github.com/Trendyol/kafka-retry-job/pull/36) ([elifbayrakdar](https://github.com/elifbayrakdar)) +- Pull Request for the issues #36 [\#37](https://github.com/Trendyol/kafka-retry-job/pull/37) ([elifbayrakdar](https://github.com/elifbayrakdar)) ## [1.12.0](https://github.com/github-changelog-generator/github-changelog-generator/tree/1.16.4) (2024-01)