https://github.com/tugayesilyurt/spring-debezium-kafka-mysql-redis-cacheable
Spring Boot - Debezium - Kafka - MySQL - Redis - Cacheable ( all in one example )
https://github.com/tugayesilyurt/spring-debezium-kafka-mysql-redis-cacheable
cacheable debezium kafka redis spring-boot
Last synced: 6 months ago
JSON representation
Spring Boot - Debezium - Kafka - MySQL - Redis - Cacheable ( all in one example )
- Host: GitHub
- URL: https://github.com/tugayesilyurt/spring-debezium-kafka-mysql-redis-cacheable
- Owner: tugayesilyurt
- Created: 2023-09-09T16:43:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-10T10:51:04.000Z (about 2 years ago)
- Last Synced: 2025-02-12T14:44:52.569Z (8 months ago)
- Topics: cacheable, debezium, kafka, redis, spring-boot
- Language: Java
- Homepage:
- Size: 200 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project Name
Spring Boot-Debezium for Change Data Capture (CDC)-Kafka-MySQL-Redis-Cacheable ( All in one comprehensive example )
## Tech Stack
- Java
- Spring Boot
- MySQL
- Apache Kafka
- Redis
- Debezium## Medium
[Read the full article on Medium](https://medium.com/@htyesilyurt/spring-boot-debezium-for-change-data-capture-cdc-kafka-mysql-redis-cacheable-all-in-one-708ef5298cba)
## Architecture

## Installation
```shell
# Clone the repository
git clone https://github.com/tugayesilyurt/spring-debezium-kafka-mysql-redis-cacheable.git# Change directory
cd spring-debezium-kafka-mysql-redis-cacheable# Install dependencies
docker-compose up -d
```- `Debezium Connector`
```java
curl --location 'http://localhost:8083/connectors' \
--header 'Content-Type: application/json' \
--data '{
"name": "property-connector",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"database.allowPublicKeyRetrieval":"true",
"database.hostname": "host.docker.internal",
"database.port": "3306",
"database.user": "debezium",
"database.password": "123456",
"database.include.list": "debezium",
"table.include.list": "debezium.debezium_property",
"topic.prefix": "property",
"schema.history.internal.kafka.bootstrap.servers": "kafka:9092",
"schema.history.internal.kafka.topic": "schema-changes.db",
"database.server.id": 1
}
}'
```- `Redis CacheManager`
```java
@Bean(value = "cacheManager")
public CacheManager redisCacheManager(RedisConnectionFactory redisConnectionFactory) {
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
.disableCachingNullValues()
.computePrefixWith(cacheName -> API_PREFIX.concat(SEPARATOR)
.concat(cacheName).concat(SEPARATOR))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json()));
redisCacheConfiguration.usePrefix();return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(redisConnectionFactory)
.cacheDefaults(redisCacheConfiguration).build();
}
```- `Cacheable`
```java
@Cacheable(value = "property", cacheManager = "cacheManager", key = "#key")
public String cacheProperty(String key, String value) {
return value;
}@CacheEvict(value = "property", cacheManager = "cacheManager", key = "#key")
public void cacheEvict(String key) {
}
```