Kafka Connect - Delete Connector with configs?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka, developed by the Apache Software Foundation, is a robust event streaming platform used to build real-time data pipelines and streaming applications. Kafka Connect is a component of Apache Kafka that simplifies integrating external systems with Kafka. This includes the ability to import data into Kafka from external sources (source connectors) as well as exporting data from Kafka to external systems (sink connectors).
One practical application of Kafka Connect is the management of data deletions. Deleting data effectively and efficiently in distributed systems like Kafka requires careful consideration, particularly when dealing with sink connectors, which export data from Kafka topics to external systems (databases, storage systems, etc.). This process ensures data consistency across systems, a crucial requirement in enterprise environments.
Kafka Connect and Delete Operations
Kafka itself doesn't directly handle delete operations in the messaging layer; instead, Kafka implements deletes through a concept called "tombstone messages". A tombstone message is a record with a specified key and a null value, signaling consumers that previous messages with the same key should be considered deleted. Managing these deletes effectively in external systems via Kafka Connect requires configuration that handles these tombstone messages appropriately.
Configuring a Sink Connector for Delete Operations
When configuring a Kafka Connect Sink connector to handle deletes, several specific configurations are important:
transformsandtransforms.tombstone-handler.type: Transformations (transforms) in Kafka Connect can be used to handle tombstone messages. By using a specific transformation that either filters out or manages these tombstone records, the connector can reflect deletes in the destination system accordingly.delete.enabled: Some sink connectors offer a specific configuration option to toggle handling of deletes. For instance, JDBC sink connector allows enabling this feature to directly perform SQLDELETEoperations in the target database.
Here is a sample configuration snippet illustrating how a JDBC sink connector might be configured to handle delete operations:
This configuration enables deletion, assuming the sink database supports it and proper indexing exists for performance considerations.
Key Configuration Details: A Summary
| Property | Description | Example Values |
connector.class | Class of the sink connector. | io.confluent.connect.jdbc.JdbcSinkConnector |
tasks.max | Maximum number of tasks for the connector. | 1 |
topics | Kafka topics to watch. | example_topic |
connection.url | Connection URL for the sink database. | jdbc:mysql://localhost:3306/database |
auto.create | Allow automatic creation of tables in the sink. | false |
delete.enabled | Enable delete operations. | true |
transforms | Define transformations. | tombstoneHandler |
transforms.tombstoneHandler.type | Specific transformation for handling tombstones. | org.apache.kafka.connect.transforms.TombstoneHandler |
Handling Complex Deletions
Deletions in a distributed system can become complex depending on the consistency and integrity requirements of the system architecture. For instance, handling deletions in systems that require strong transactional consistency might involve additional mechanisms like two-phase commits or compensating transactions.
Conclusion
Handling data deletions through Kafka Connect requires a thorough understanding of Kafka's tombstone messages and how they can be used effectively within sink connectors. By properly configuring these connectors, it is possible to ensure data consistency and integrity across distributed systems, aligning with the business requirements of real-time data processing and analytics frameworks. In high-volume environments, careful planning and resource allocation are likewise essential to maintain system performance and reliability.
Related reading
- Kafka Connect - do the workers need direct communication with each other
- Kafka Connect - Failed to commit offsets and flush
- Kafka Connect - Failed to flush, timed out while waiting for producer to flush outstanding messages
- Kafka Connect - How to delete a connector
- kafka connect - jdbc sink sql exception
- Kafka Connect - JDBC Source Connector - Setting Avro Schema
- Kafka Connect | Cannot complete request because of a conflicting operation
- Kafka Connect Alerting Options?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.