{"id":28103476,"url":"https://github.com/eddie4k-code/kafka-connect-deduplicator","last_synced_at":"2025-05-13T20:38:01.178Z","repository":{"id":287109743,"uuid":"961231200","full_name":"Eddie4k-code/kafka-connect-deduplicator","owner":"Eddie4k-code","description":"A Kafka Connect Single Message Transformation that will avoid duplicate messages being delivered.","archived":false,"fork":false,"pushed_at":"2025-04-23T03:15:10.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T04:23:51.879Z","etag":null,"topics":["apache-kafka","duplicate-detection","kafka","kafka-connect","kafka-connect-transformations","kafka-connect-transforms","single-message-transforms","smt"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Eddie4k-code.png","metadata":{"files":{"readme":"ReadME.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-06T03:42:42.000Z","updated_at":"2025-04-23T03:14:50.000Z","dependencies_parsed_at":"2025-04-10T02:42:59.218Z","dependency_job_id":"fc012f80-c282-48b1-a860-48252467b11c","html_url":"https://github.com/Eddie4k-code/kafka-connect-deduplicator","commit_stats":null,"previous_names":["eddie4k-code/duplicate-message-detector-kafka-connect-smt","eddie4k-code/kafka-connect-deduplicator"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eddie4k-code%2Fkafka-connect-deduplicator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eddie4k-code%2Fkafka-connect-deduplicator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eddie4k-code%2Fkafka-connect-deduplicator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eddie4k-code%2Fkafka-connect-deduplicator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eddie4k-code","download_url":"https://codeload.github.com/Eddie4k-code/kafka-connect-deduplicator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254022075,"owners_count":22001053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-kafka","duplicate-detection","kafka","kafka-connect","kafka-connect-transformations","kafka-connect-transforms","single-message-transforms","smt"],"created_at":"2025-05-13T20:37:58.828Z","updated_at":"2025-05-13T20:38:01.166Z","avatar_url":"https://github.com/Eddie4k-code.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔁 DuplicateMessageDetector\n\nA Kafka Connect **Single Message Transform (SMT)** that detects and filters out duplicate messages based on a **unique key** field in the record. This is useful in streaming pipelines where upstream systems may occasionally produce repeated records.\n\nSupports both **schemaless** and **schema-based** records, and allows flexible configuration of how to find and identify the unique key.\n\n---\n\n## ⚙️ Features\n\n- Detects and drops duplicate Kafka messages\n- Configurable unique key for identifying duplicates\n- Supports both schema-based and schemaless records\n- Supports field search strategies: `recursive` or `path`\n- Pluggable cache strategies (currently supports: `in_memory`)\n- Automatic cache clearing based on a specified ms interval\n\n⚠️ Warning: In-memory caching is not recommended for production use. Consider using a distributed cache like Redis for better reliability and scalability.\n\n---\n\n\n## 💡 Why Use This?\n\nEven though some Kafka Connect connectors and Kafka clients support **exactly-once semantics**, duplicates can and *do* still happen in real-world pipelines due to:\n\n- 🔁 **Connector restarts or rebalancing**\n- 🐛 **Bugs in connectors or custom SMTs (Single Message Transforms)**\n- 🧱 **Reprocessing historical data**\n- ⛓️ **Complex pipelines** with multiple Kafka topics, microservices, or enrichment layers\n- 💥 **Failures during sink operations** (e.g. DB write failure, API timeouts)\n\nThis tool provides a **defense-in-depth** layer to:\n- 🚫 Detect and ignore duplicates based on configurable fields\n- 🧪 Enhance observability by surfacing duplicate messages\n- 💼 Help teams working with **non-idempotent sinks** (e.g., databases, payment APIs)\n\nUse it as a **pluggable strategy** for duplicate detection when reliability and correctness are key.\n\n## 🛠 Configuration\n\n| Config Key              | Type    | Required | Default     | Description |\n|------------------------|---------|----------|-------------|-------------|\n| `unique.key`           | string  | ✅        | -           | The field name used to uniquely identify each record |\n| `cache.method`         | string  | ❌        | `in_memory` | Options: `in_memory`, `redis` |\n| `field.search.strategy`| string  | ✅        | `path`      | Options: `path`, `recursive` |\n| `enable.cache.clear`   | boolean | ❌        | `false`     | Enables periodic cache clearing |\n| `clear.cache.ms`       | long    | ❌        | `1000`      | Interval in milliseconds for clearing the cache |\n\n---\n\n\n## 🔍 Search Strategies\n\nThe `field.search.strategy` config allows two strategies for finding the `unique.key` in a message:\n\n### 1. `path` (Default)\n- **How it works**: Uses dot-notation to traverse nested fields (`a.b.c`).\n- **Performance**: ✅ Fastest. Direct lookup without unnecessary recursion.\n- **Best for**: Consistently structured records with known nesting.\n- **Fails if**: Any part of the path doesn't exist.\n\n\u003e 🧪 Example:\n\u003e \n\u003e With record:\n\u003e ```json\n\u003e {\n\u003e   \"outer\": {\n\u003e     \"inner\": {\n\u003e       \"id\": \"abc123\"\n\u003e     }\n\u003e   }\n\u003e }\n\u003e ```\n\u003e And `unique.key=outer.inner.id` ➜ value `\"abc123\"` is found.\n\n---\n\n### 2. `recursive`\n- **How it works**: Recursively inspects all nested fields until it finds a match for the field name.\n- **Performance**: ❌ Slower. Visits lots of nested fields before finding match.\n- **Best for**: Inconsistent or deeply nested record structures.\n- **Fails if**: Field name doesn't exist at all (but less brittle than `path`).\n\n\u003e 🧪 Example:\n\u003e With record:\n\u003e ```json\n\u003e {\n\u003e   \"meta\": {\n\u003e     \"tracking\": {\n\u003e       \"id\": \"abc123\"\n\u003e     }\n\u003e   }\n\u003e }\n\u003e ```\n\u003e And `unique.key=id` ➜ value `\"abc123\"` is found by deep search.\n\n---\n\n## 🧠 Cache Strategies\n\n### `in_memory`\n- Keeps a simple map of keys in memory.\n- ✅ Fast, but not distributed.\n- ❌ All state is lost on restart.\n\n### `redis` (Planned or in development)\n- Distributed cache.\n- Survives process restarts.\n- Slower than in-memory, but suitable for horizontal scaling.\n\n---\n\n\n\n## 🧹 Automatic Cache Clearing\nTo prevent unbounded memory growth or to support time-based deduplication, this transformation supports automatic cache clearing at a configurable interval.\n\n### 🔧 Configuration Options\n\n| Property             | Type    | Default | Description                                      |\n|----------------------|---------|---------|--------------------------------------------------|\n| `enable.cache.clear` | boolean | `false` | Whether to enable automatic cache clearing       |\n| `clear.cache.ms`     | long    | `60000` | How often (in milliseconds) to clear the cache   |\n\n### ⚠️ Performance Considerations\nThe cache is cleared in a background thread, independently of record processing.\n\nClearing the cache too frequently (e.g., every few milliseconds) may reduce deduplication accuracy and introduce unnecessary CPU overhead.\n\nA thread-safe cache (like ConcurrentHashMap) is used by default to ensure safe access from multiple threads.\n\nFor Redis-based caches, frequent clearing could increase I/O and reduce efficiency — consider using Redis TTLs configuration instead. (Coming soon)\n\n## Download\nYou can download the latest compiled .jar file from the Releases section of this repository.\n\n🔽 Latest Release\nGo to the Releases page.\n\nFind the most recent version (e.g., v1.0.0).\n\nDownload the .jar file under Assets.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddie4k-code%2Fkafka-connect-deduplicator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddie4k-code%2Fkafka-connect-deduplicator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddie4k-code%2Fkafka-connect-deduplicator/lists"}