Oracle GoldenGate (a.k.a ogg) is a managed service providing a real-time data mesh platform, which uses replication to keep data highly available, and enabling real-time analysis. Customers can design, execute, and monitor their data replication and stream data processing solutions without the need to allocate or manage compute environments. Ogg provides a format schema for changelog and supports to serialize messages using JSON.

Seatunnel supports to interpret Ogg JSON messages as INSERT/UPDATE/DELETE messages into seatunnel system. This is useful in many cases to leverage this feature, such as

  1. synchronizing incremental data from databases to other systems
  2. auditing logs
  3. real-time materialized views on databases
  4. temporal join changing history of a database table and so on.

Seatunnel also supports to encode the INSERT/UPDATE/DELETE messages in Seatunnel as Ogg JSON messages, and emit to storage like Kafka. However, currently Seatunnel can’t combine UPDATE_BEFORE and UPDATE_AFTER into a single UPDATE message. Therefore, Seatunnel encodes UPDATE_BEFORE and UPDATE_AFTER as DELETE and INSERT Ogg messages.

Format Options

Option Default Required Description
format (none) yes Specify what format to use, here should be ‘-json’.
ogg_json.ignore-parse-errors false no Skip fields and rows with parse errors instead of failing. Fields are set to null in case of errors.
ogg_json.database.include (none) no An optional regular expression to only read the specific databases changelog rows by regular matching the “database” meta field in the Canal record. The pattern string is compatible with Java’s Pattern.
ogg_json.table.include (none) no An optional regular expression to only read the specific tables changelog rows by regular matching the “table” meta field in the Canal record. The pattern string is compatible with Java’s Pattern.

How to use Ogg format

Kafka uses example

Ogg provides a unified format for changelog, here is a simple example for an update operation captured from a Oracle products table:

  1. {
  2. "before": {
  3. "id": 111,
  4. "name": "scooter",
  5. "description": "Big 2-wheel scooter",
  6. "weight": 5.18
  7. },
  8. "after": {
  9. "id": 111,
  10. "name": "scooter",
  11. "description": "Big 2-wheel scooter",
  12. "weight": 5.15
  13. },
  14. "op_type": "U",
  15. "op_ts": "2020-05-13 15:40:06.000000",
  16. "current_ts": "2020-05-13 15:40:07.000000",
  17. "primary_keys": [
  18. "id"
  19. ],
  20. "pos": "00000000000000000000143",
  21. "table": "PRODUCTS"
  22. }

Note: please refer to Debezium documentation about the meaning of each fields.

The Oracle products table has 4 columns (id, name, description and weight). The above JSON message is an update change event on the products table where the weight value of the row with id = 111 is changed from 5.18 to 5.15. Assuming the messages have been synchronized to Kafka topic products_binlog, then we can use the following Seatunnel to consume this topic and interpret the change events.

  1. env {
  2. parallelism = 1
  3. job.mode = "STREAMING"
  4. }
  5. source {
  6. Kafka {
  7. bootstrap.servers = "127.0.0.1:9092"
  8. topic = "ogg"
  9. result_table_name = "kafka_name"
  10. start_mode = earliest
  11. schema = {
  12. fields {
  13. id = "int"
  14. name = "string"
  15. description = "string"
  16. weight = "double"
  17. }
  18. },
  19. format = ogg_json
  20. }
  21. }
  22. sink {
  23. jdbc {
  24. url = "jdbc:mysql://127.0.0.1/test"
  25. driver = "com.mysql.cj.jdbc.Driver"
  26. user = "root"
  27. password = "12345678"
  28. table = "ogg"
  29. primary_keys = ["id"]
  30. }
  31. }