Change Data Capture - Software Design Pattern
Change Data Capture or CDC is an approach to data integration, generally used in enterprise applications.
What is Change Data Capture ?
There are 3 things which happens within CDC products:
- Identification of data
- Capture of changes
- Delivery of changes
Debezium is one of the CDC products, which is
- open-source
- distributed platform
In this post, I wanted to take a new approach to writing blog posts. Code commentaries.
Basically there are 2 motivations:
- I want to read more code and understand code
- This is something I have not done yet, in my blogging efforts.
Code commentary:
Language: Java
Repository: Debezium
Package: package io.debezium.pipeline;
Class: ChangeEventSourceCoordinator
Github Path: https://github.com/debezium/debezium/blob/master/debezium-core/src/main/java/io/debezium/pipeline/ChangeEventSourceCoordinator.java
Commentary:
-
At line: 41, @ThreadSafe annotation , with this annotation. This annotation generally captures design intent. Basically this annotation is used to document thread safety, denoting that, this class:
ChangeEventSourceCoordinator
is thread-safe. You can check, that one of the recommendations laid out by SEI CERT Oracle Coding Standard for Java, is to document thread safety. This can be added to our kitty of best practices for coding. -
At line: 46, Usage of Duration class:
-
private static final Duration SHUTDOWN_WAIT_TIMEOUT = Duration.ofSeconds(90);
Duration class was introduced as part of Java 8. This is later used within stop() method, as a parameter to
awaitTermination()
for shutting down executor. Generally the old way of coding is to use aLong
to have some value of milliseconds. But, using Duration is a cleaner approach and improves readability too.
-
-
Then, we can see the organization of import statements.
- Firstly, imports related to java jdk
- Secondly, imports to external 3rd party, for example: sl4j for logger component, kafka for kafka-connect component
- Thirdly, imports from own component ( from self )