-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debezium.kt
37 lines (31 loc) · 1.75 KB
/
Debezium.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package gymclass.fixtures.containers
import io.debezium.testing.testcontainers.ConnectorConfiguration
import io.debezium.testing.testcontainers.DebeziumContainer
import org.slf4j.LoggerFactory
import org.testcontainers.containers.output.Slf4jLogConsumer
class Debezium(kafka: Kafka, postgres: Postgres) {
private val LOGGER = LoggerFactory.getLogger(Debezium::class.java)
val container = DebeziumContainer("quay.io/debezium/connect:2.4.1.Final")
.withNetwork(kafka.container.network)
.withKafka(kafka.container)
.withLogConsumer(Slf4jLogConsumer(LOGGER))
.dependsOn(kafka.container)
.also {
it.start()
val config = ConnectorConfiguration.forJdbcContainer(postgres.container)
.with("transforms", "outbox")
.with("plugin.name", "pgoutput")
.with("topic.prefix", "gymclass")
.with("table.include.list", "public.outbox")
.with("table.whitelist", "public.outbox")
.with("value.converter", "io.debezium.converters.BinaryDataConverter")
.with("value.converter.delegate.converter.type", "org.apache.kafka.connect.json.JsonConverter")
.with("value.converter.delegate.converter.type.schemas.enable", "false")
.with("transforms.outbox.table.field.event.key", "id")
.with("transforms.outbox.table.field.event.type", "event_type")
.with("transforms.outbox.route.tombstone.on.empty.payload", "true")
.with("transforms.outbox.route.topic.replacement", "gymclass.events")
.with("transforms.outbox.type", "io.debezium.transforms.outbox.EventRouter")
it.registerConnector("my-connector", config)
}
}