File tree 4 files changed +104
-0
lines changed
4 files changed +104
-0
lines changed Original file line number Diff line number Diff line change
1
+ version : ' 3.8'
2
+ services :
3
+ # https://hub.docker.com/_/postgres
4
+ db :
5
+ container_name : db
6
+ image : postgres
7
+ restart : always
8
+ environment :
9
+ - POSTGRES_USER=postgres
10
+ - POSTGRES_PASSWORD=postgres
11
+ ports :
12
+ - ' 5432:5432'
13
+ volumes :
14
+ - ./postgres_data:/var/lib/postgresql/data
15
+ - ./src/main/resources/dml/schema.sql:/docker-entrypoint-initdb.d/schema.sql
16
+ command : [ "postgres", "-c", "wal_level=logical" ]
17
+ adminer :
18
+ image : adminer
19
+ restart : always
20
+ ports :
21
+ - 8081:8081
Original file line number Diff line number Diff line change 18
18
<maven .compiler.target>21</maven .compiler.target>
19
19
<project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
20
20
<spring-boot .version>2.7.18</spring-boot .version>
21
+ <postgresql .version>42.2.5</postgresql .version>
22
+ <debezium .version>2.7.2.Final</debezium .version>
21
23
</properties >
22
24
23
25
<dependencies >
50
52
<version >1.18.30</version >
51
53
<scope >provided</scope >
52
54
</dependency >
55
+
56
+ <dependency >
57
+ <groupId >org.postgresql</groupId >
58
+ <artifactId >postgresql</artifactId >
59
+ <version >${postgresql.version} </version >
60
+ </dependency >
61
+
62
+ <!-- Debezium -->
63
+ <dependency >
64
+ <groupId >io.debezium</groupId >
65
+ <artifactId >debezium-embedded</artifactId >
66
+ <version >${debezium.version} </version >
67
+ </dependency >
68
+ <dependency >
69
+ <groupId >io.debezium</groupId >
70
+ <artifactId >debezium-connector-postgres</artifactId >
71
+ <version >${debezium.version} </version >
72
+ </dependency >
53
73
</dependencies >
54
74
55
75
<dependencyManagement >
86
106
</execution >
87
107
</executions >
88
108
</plugin >
109
+
110
+ <plugin >
111
+ <groupId >io.fabric8</groupId >
112
+ <artifactId >docker-maven-plugin</artifactId >
113
+ <version >0.45.0</version >
114
+ <configuration ></configuration >
115
+ <executions >
116
+ <execution >
117
+ <id >start</id >
118
+ <!-- <phase>pre-integration-test</phase>-->
119
+ <phase >generate-test-resources</phase >
120
+ <goals >
121
+ <goal >build</goal >
122
+ <goal >start</goal >
123
+ </goals >
124
+ </execution >
125
+ <execution >
126
+ <id >stop</id >
127
+ <phase >post-integration-test</phase >
128
+ <goals >
129
+ <goal >stop</goal >
130
+ </goals >
131
+ </execution >
132
+ <execution >
133
+ <id >stop-pre</id >
134
+ <phase >clean</phase >
135
+ <goals >
136
+ <goal >stop</goal >
137
+ </goals >
138
+ </execution >
139
+ </executions >
140
+ </plugin >
141
+
89
142
</plugins >
90
143
</build >
91
144
Original file line number Diff line number Diff line change 5
5
https://www.baeldung.com/debezium-intro
6
6
https://ishansoninitj.medium.com/change-data-capture-cdc-using-debezium-in-a-springboot-application-97ddde8b991a
7
7
https://gist.github.com/tzolov/c3bfa56237f0d4ceb53a93b6c80436e3
8
+ https://github.com/tzolov/cdc-debezium/tree/master
8
9
9
10
### Avro
10
11
Original file line number Diff line number Diff line change
1
+ -- ----/* schema.*/
2
+ -- - https://github.com/hackmods/The-the_simpsons-SQL
3
+ CREATE SCHEMA the_simpsons ;
4
+ -- ----/* character.*/
5
+ CREATE TABLE IF NOT EXISTS the_simpsons .character (
6
+ id SERIAL NOT NULL PRIMARY KEY ,
7
+ name VARCHAR NOT NULL ,
8
+ surname VARCHAR NOT NULL ,
9
+ update_ts TIMESTAMP DEFAULT current_timestamp NOT NULL
10
+ );
11
+ -- ----/*Insertion des données dans la table character.*/
12
+ INSERT INTO the_simpsons .character (nom, pays) VALUES
13
+ (' Homer' ,' Simpson' ),
14
+ (' Bart' ,' Simpson' ),
15
+ (' Lisa' ,' Simpson' );
16
+ -- ----/*Trigger pour maj de la date "update_ts"*/
17
+ CREATE OR REPLACE FUNCTION maj_date ()
18
+ RETURNS TRIGGER AS $$
19
+ BEGIN
20
+ NEW .update_ts := NOW();
21
+ RETURN NEW;
22
+ END;
23
+ $$ LANGUAGE plpgsql;
24
+ CREATE TRIGGER maj_date_trigger
25
+ BEFORE INSERT OR UPDATE ON the_simpsons .character
26
+ FOR EACH ROW
27
+ EXECUTE FUNCTION maj_date();
28
+ -- ----/*Tres utile pour obtenir des details dans la section before de la donnée*/
29
+ ALTER TABLE the_simpsons .character REPLICA IDENTITY FULL;
You can’t perform that action at this time.
0 commit comments