This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4ad0b6105305 CAMEL-27398, CAMEL-27399, CAMEL-27400: camel-debezium -
check the offset file at startup, keep the column order, depend on
debezium-storage-kafka (#30618)
4ad0b6105305 is described below
commit 4ad0b6105305e3dc5ee617ac34e2814f8a85f7a4
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 23 09:52:15 2026 +0100
CAMEL-27398, CAMEL-27399, CAMEL-27400: camel-debezium - check the offset
file at startup, keep the column order, depend on debezium-storage-kafka
(#30618)
With Kafka 4.x, the embedded engine creates the offset stores of Kafka
(the default file store and the Kafka topic store) through the
OffsetStoreProvider of debezium-storage-kafka, which camel-debezium only got
as a transitive dependency of debezium-embedded. It is now declared next to
debezium-storage-file, with a test that the providers are found.
camel-debezium - DebeziumTypeConverter.toMap keeps the order of the fields
of the Struct
The Struct to Map converter built a HashMap, so the JSON of the Map lost the
order of the columns of the table. It now builds a LinkedHashMap in the
order of the fields of the schema of the Struct, nested Structs (also in a
list) included, and a map field keeps its order.
camel-debezium - fail at startup when the folder of offsetStorageFileName
does not exist or cannot be written
With the default file offset store, the consumer started when the folder of
offsetStorageFileName did not exist, every save of the position failed with
only a WARN, and a restart sent everything again, the snapshot included.
validateDebeziumEmbeddedEngineConfiguration now checks the files as the
engine gets them (the additional properties included): the folder of the
offset file must exist and be writable, and the file, if it exists, must be
writable. With the file schema history, schemaHistoryInternalFileFilename
must be set and writable; its folders may be missing, as Debezium creates
them. The error names the file. A configuration that cannot be built yet is
left to the connector validation, and logged at DEBUG.
The tests use offset files in folders that exist, the docs examples no
longer use /usr, and the docs and the upgrade guide say where the position
is saved, the Kafka store included.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/docs/debezium-db2-component.adoc | 23 +++-
.../catalog/docs/debezium-mongodb-component.adoc | 20 ++-
.../catalog/docs/debezium-mysql-component.adoc | 23 +++-
.../catalog/docs/debezium-oracle-component.adoc | 23 +++-
.../catalog/docs/debezium-postgres-component.adoc | 20 ++-
.../catalog/docs/debezium-sqlserver-component.adoc | 23 +++-
.../component/debezium/DebeziumTypeConverter.java | 13 +-
.../EmbeddedDebeziumConfiguration.java | 97 ++++++++++++++
.../component/debezium/DebeziumComponentTest.java | 2 +-
.../DebeziumConsumerEngineFailureTest.java | 7 +
.../debezium/DebeziumOffsetStoreProvidersTest.java | 44 ++++++
.../debezium/DebeziumTypeConverterTest.java | 29 ++++
.../EmbeddedDebeziumConfigurationTest.java | 2 +-
.../EmbeddedDebeziumStorageFilesTest.java | 147 +++++++++++++++++++++
.../camel-debezium/camel-debezium-common/pom.xml | 6 +
.../src/main/docs/debezium-db2-component.adoc | 23 +++-
.../debezium/DebeziumDb2ComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../src/main/docs/debezium-mongodb-component.adoc | 20 ++-
.../debezium/DebeziumMongodbComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../src/main/docs/debezium-mysql-component.adoc | 23 +++-
.../debezium/DebeziumMySqlComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../src/main/docs/debezium-oracle-component.adoc | 23 +++-
.../debezium/DebeziumOracleComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../src/main/docs/debezium-postgres-component.adoc | 20 ++-
.../debezium/DebeziumPostgresComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../main/docs/debezium-sqlserver-component.adoc | 23 +++-
.../debezium/DebeziumSqlserverComponentTest.java | 8 +-
...ConnectorEmbeddedDebeziumConfigurationTest.java | 6 +-
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 13 ++
34 files changed, 610 insertions(+), 98 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-db2-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-db2-component.adoc
index 694709d2ff5a..bbb52dab3932 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-db2-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-db2-component.adoc
@@ -89,6 +89,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -101,7 +116,7 @@ Java::
+
[source,java]
----
-from("debezium-db2:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -116,7 +131,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-db2:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -135,12 +150,12 @@ YAML::
from:
uri: debezium-db2:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mongodb-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mongodb-component.adoc
index dbcbbfb31b9d..a29c8d3b54dc 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mongodb-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mongodb-component.adoc
@@ -99,6 +99,18 @@ then set only when the transformation adds the operation,
with `additionalProper
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -111,7 +123,7 @@ Java::
+
[source,java]
----
-from("debezium-mongodb:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -131,7 +143,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-mongodb:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -156,12 +168,12 @@ YAML::
from:
uri: debezium-mongodb:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
mongodbConnectionString: "mongodb://localhost:27017/?replicaSet=rs0"
mongodbUser: debezium
mongodbPassword: dbz
topicPrefix: dbserver1
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mysql-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mysql-component.adoc
index ff87d1557167..8f3db6306db0 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mysql-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-mysql-component.adoc
@@ -100,6 +100,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -112,7 +127,7 @@ Java::
+
[source,java]
----
-from("debezium-mysql:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-mysql:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -128,7 +143,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-mysql:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-mysql:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -148,12 +163,12 @@ YAML::
from:
uri: debezium-mysql:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-oracle-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-oracle-component.adoc
index d2555e6dcf69..1176215fd839 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-oracle-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-oracle-component.adoc
@@ -87,6 +87,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -99,7 +114,7 @@ Java::
+
[source,java]
----
-from("debezium-oracle:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-oracle:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -114,7 +129,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-oracle:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-oracle:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -133,12 +148,12 @@ YAML::
from:
uri: debezium-oracle:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-postgres-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-postgres-component.adoc
index 0f7e6e9de9a6..288385b57d43 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-postgres-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-postgres-component.adoc
@@ -87,6 +87,18 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -99,7 +111,7 @@ Java::
+
[source,java]
----
-from("debezium-postgres:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-postgres:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -114,7 +126,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-postgres:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-postgres:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -133,12 +145,12 @@ YAML::
from:
uri: debezium-postgres:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-sqlserver-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-sqlserver-component.adoc
index 43913d21386c..9f11c676af6a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-sqlserver-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/debezium-sqlserver-component.adoc
@@ -85,6 +85,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -97,7 +112,7 @@ Java::
+
[source,java]
----
-from("debezium-sqlserver:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-sqlserver:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -112,7 +127,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-sqlserver:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-sqlserver:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -131,12 +146,12 @@ YAML::
from:
uri: debezium-sqlserver:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/DebeziumTypeConverter.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/DebeziumTypeConverter.java
index a9bac9778c38..ca903a446902 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/DebeziumTypeConverter.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/DebeziumTypeConverter.java
@@ -17,7 +17,7 @@
package org.apache.camel.component.debezium;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -31,16 +31,17 @@ public final class DebeziumTypeConverter {
}
/**
- * Convert {@link Struct} to {@link HashMap}. A nested {@link Struct} is
converted to a {@link Map} too, also inside
- * a list (an array field) or as the value of a map (a map field). As a
result of the conversion, the schema data
- * will be lost which is expected.
+ * Convert {@link Struct} to a {@link Map}, in the order of the fields of
the schema of the Struct (the order of the
+ * columns of the table), so the JSON of the Map has the columns in that
order. A nested {@link Struct} is converted
+ * to a {@link Map} too, also inside a list (an array field) or as the
value of a map (a map field, which keeps its
+ * order). As a result of the conversion, the schema data will be lost
which is expected.
*
* @param struct
* @return {@link Map}
*/
@Converter
public static Map<String, Object> toMap(final Struct struct) {
- final HashMap<String, Object> fieldsToValues = new HashMap<>();
+ final Map<String, Object> fieldsToValues = new LinkedHashMap<>();
struct.schema().fields().forEach(field ->
fieldsToValues.put(field.name(), convertValue(struct.get(field))));
@@ -56,7 +57,7 @@ public final class DebeziumTypeConverter {
list.forEach(element -> answer.add(convertValue(element)));
return answer;
} else if (value instanceof Map<?, ?> map) {
- final Map<Object, Object> answer = new HashMap<>();
+ final Map<Object, Object> answer = new LinkedHashMap<>();
map.forEach((key, element) -> answer.put(convertValue(key),
convertValue(element)));
return answer;
}
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfiguration.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfiguration.java
index 07aed26cd017..5357dc409d8e 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfiguration.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfiguration.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.component.debezium.configuration;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
@@ -31,10 +34,18 @@ import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
import org.apache.camel.util.ObjectHelper;
import org.apache.kafka.connect.json.JsonConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@UriParams
public abstract class EmbeddedDebeziumConfiguration implements Cloneable {
+ private static final Logger LOG =
LoggerFactory.getLogger(EmbeddedDebeziumConfiguration.class);
+
+ // the properties of the file schema history of Debezium (MySQL, SQL
Server, Oracle, Db2)
+ private static final String SCHEMA_HISTORY_INTERNAL =
"schema.history.internal";
+ private static final String SCHEMA_HISTORY_INTERNAL_FILE_FILENAME =
"schema.history.internal.file.filename";
+
private static final String LABEL_NAME = "consumer";
private Class<?> connectorClass;
@@ -241,9 +252,95 @@ public abstract class EmbeddedDebeziumConfiguration
implements Cloneable {
.format("Required field 'offsetStorageFileName' must be
set since 'offsetStorage' is set to '%s'",
DebeziumConstants.DEFAULT_OFFSET_STORAGE));
}
+ return validateStorageFiles();
+ }
+
+ /**
+ * Checks the files that Debezium writes its position and its schema
history to, as the engine gets them (the
+ * additional properties included), so a consumer whose position cannot be
saved fails when it starts instead of
+ * logging a WARN on every save and sending everything again, the snapshot
included, after a restart.
+ * <p>
+ * The file offset store of Kafka writes the file in its folder, which
must exist. The file schema history of
+ * Debezium creates its folders, so only a folder that cannot be created
is an error there.
+ */
+ private ConfigurationValidation validateStorageFiles() {
+ final Configuration config;
+ try {
+ config = createDebeziumConfiguration();
+ } catch (RuntimeException e) {
+ // an incomplete configuration: the connector validation reports
what is missing
+ LOG.debug("Cannot check the storage files, as the Debezium
configuration cannot be created: {}", e.getMessage(),
+ e);
+ return ConfigurationValidation.valid();
+ }
+ if
(DebeziumConstants.DEFAULT_OFFSET_STORAGE.equals(config.getString(AsyncEmbeddedEngine.OFFSET_STORAGE)))
{
+ String problem =
storageFileProblem(config.getString(AsyncEmbeddedEngine.OFFSET_STORAGE_FILE_FILENAME),
false);
+ if (problem != null) {
+ return ConfigurationValidation.notValid(
+ "The file of offsetStorageFileName " + problem + ".
Debezium saves its position to this file:"
+ + " without it, a
restart sends all the changes again.");
+ }
+ }
+ String history = config.getString(SCHEMA_HISTORY_INTERNAL);
+ if (history != null && history.endsWith(".FileSchemaHistory")) {
+ String file =
config.getString(SCHEMA_HISTORY_INTERNAL_FILE_FILENAME);
+ if (isFieldValueNotSet(file)) {
+ return ConfigurationValidation.notValid(
+ "Required field 'schemaHistoryInternalFileFilename'
must be set since 'schemaHistoryInternal'"
+ + " is set to '" +
history + "'");
+ }
+ String problem = storageFileProblem(file, true);
+ if (problem != null) {
+ return ConfigurationValidation.notValid("The file of
schemaHistoryInternalFileFilename " + problem);
+ }
+ }
return ConfigurationValidation.valid();
}
+ /**
+ * Why the file cannot be written, or null when it can.
+ *
+ * @param file the file
+ * @param createsFolders whether the store creates the folders of the file
that do not exist
+ */
+ static String storageFileProblem(String file, boolean createsFolders) {
+ if (isFieldValueNotSet(file)) {
+ return null;
+ }
+ Path path;
+ try {
+ path = Path.of(file).toAbsolutePath().normalize();
+ } catch (InvalidPathException e) {
+ return "(" + file + ") is not a valid path";
+ }
+ if (Files.isDirectory(path)) {
+ return "(" + path + ") is a folder, not a file";
+ }
+ if (Files.exists(path)) {
+ return Files.isWritable(path) ? null : "(" + path + ") cannot be
written";
+ }
+ Path folder = path.getParent();
+ if (createsFolders) {
+ Path existing = folder;
+ while (existing != null && !Files.exists(existing)) {
+ existing = existing.getParent();
+ }
+ if (existing == null || !Files.isDirectory(existing) ||
!Files.isWritable(existing)) {
+ return "(" + path + ") is in a folder that cannot be created,
as "
+ + (existing != null ? existing : folder) + " cannot be
written";
+ }
+ return null;
+ }
+ if (folder == null || !Files.isDirectory(folder)) {
+ return "(" + path + ") is in the folder " + folder + ", which does
not exist: create it, or use a file in"
+ + " a folder that exists";
+ }
+ if (!Files.isWritable(folder)) {
+ return "(" + path + ") is in the folder " + folder + ", which
cannot be written";
+ }
+ return null;
+ }
+
protected static boolean isFieldValueNotSet(final Object field) {
return ObjectHelper.isEmpty(field);
}
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumComponentTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumComponentTest.java
index 5f9f4f007d12..75f6e58378e0 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumComponentTest.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumComponentTest.java
@@ -37,7 +37,7 @@ public class DebeziumComponentTest extends CamelTestSupport {
params.put("extra.1", 789);
params.put("extra.3", "test.extra.3");
- configuration.setOffsetStorageFileName("/test");
+ configuration.setOffsetStorageFileName("target/offset-test");
configuration.setTestFilePath(Paths.get("."));
configuration.setTopicConfig("test_conf");
configuration.setAdditionalProperties(params);
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumConsumerEngineFailureTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumConsumerEngineFailureTest.java
index bd328327f5b3..be9dab502ad3 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumConsumerEngineFailureTest.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumConsumerEngineFailureTest.java
@@ -35,6 +35,7 @@ import org.apache.camel.health.HealthCheck;
import org.apache.camel.spi.ExceptionHandler;
import org.apache.camel.test.junit6.CamelTestSupport;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -54,6 +55,12 @@ public class DebeziumConsumerEngineFailureTest extends
CamelTestSupport {
private static final Path TEST_OFFSET_STORE_PATH
= Paths.get("target/data",
"camel-debezium-engine-failure-offset-store.txt").toAbsolutePath();
+ @BeforeAll
+ static void createFolder() throws IOException {
+ // the folder of the offset file must exist when the endpoint is
created, which is before beforeEach
+ Files.createDirectories(TEST_OFFSET_STORE_PATH.getParent());
+ }
+
@BeforeEach
public void beforeEach() throws IOException {
IoUtil.createFile(TEST_FILE_PATH);
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumOffsetStoreProvidersTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumOffsetStoreProvidersTest.java
new file mode 100644
index 000000000000..420ef7903a71
--- /dev/null
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumOffsetStoreProvidersTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.debezium;
+
+import java.util.List;
+import java.util.ServiceLoader;
+
+import io.debezium.spi.storage.OffsetStoreProvider;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * With Kafka 4.x, the embedded engine creates the offset stores of Kafka
through the OffsetStoreProvider of
+ * debezium-storage-kafka, as the Kafka classes no longer have the no-argument
constructor it used: camel-debezium
+ * depends on it directly.
+ */
+class DebeziumOffsetStoreProvidersTest {
+
+ @Test
+ void theOffsetStoresOfKafkaHaveTheirProvider() {
+ List<String> providers =
ServiceLoader.load(OffsetStoreProvider.class).stream()
+ .map(p -> p.type().getName()).toList();
+
+ //
offsetStorage=org.apache.kafka.connect.storage.KafkaOffsetBackingStore
+
assertTrue(providers.contains("io.debezium.storage.kafka.offset.KafkaOffsetStoreProvider"),
providers.toString());
+ // the default, org.apache.kafka.connect.storage.FileOffsetBackingStore
+
assertTrue(providers.contains("io.debezium.storage.kafka.offset.KafkaFileOffsetProvider"),
providers.toString());
+ }
+}
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumTypeConverterTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumTypeConverterTest.java
index fde7b1000263..4b24d91ec724 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumTypeConverterTest.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/DebeziumTypeConverterTest.java
@@ -113,4 +113,33 @@ public class DebeziumTypeConverterTest {
return value;
}
+
+ @Test
+ void testToMapKeepsTheOrderOfTheFields() {
+ // the order of the columns of the table, which a HashMap would lose
+ Schema detailsSchema = SchemaBuilder.struct()
+ .field("zip", SchemaBuilder.STRING_SCHEMA)
+ .field("city", SchemaBuilder.STRING_SCHEMA)
+ .field("country", SchemaBuilder.STRING_SCHEMA)
+ .build();
+ Schema valueSchema = SchemaBuilder.struct()
+ .field("id", SchemaBuilder.INT32_SCHEMA)
+ .field("name", SchemaBuilder.STRING_SCHEMA)
+ .field("price", SchemaBuilder.FLOAT64_SCHEMA)
+ .field("added", SchemaBuilder.STRING_SCHEMA)
+ .field("address", detailsSchema)
+ .field("lines", SchemaBuilder.array(detailsSchema).build())
+ .build();
+ Struct address = new Struct(detailsSchema).put("zip",
"8000").put("city", "Aarhus").put("country", "DK");
+ Struct inputValue = new Struct(valueSchema)
+ .put("id", 1).put("name", "camel").put("price",
9.95).put("added", "2026-11-22")
+ .put("address", address).put("lines", List.of(address));
+
+ Map<String, Object> outputValue =
DebeziumTypeConverter.toMap(inputValue);
+
+ assertEquals(List.of("id", "name", "price", "added", "address",
"lines"), List.copyOf(outputValue.keySet()));
+ assertEquals(List.of("zip", "city", "country"), List.copyOf(((Map<?,
?>) outputValue.get("address")).keySet()));
+ Map<?, ?> line = (Map<?, ?>) ((List<?>)
outputValue.get("lines")).get(0);
+ assertEquals(List.of("zip", "city", "country"),
List.copyOf(line.keySet()));
+ }
}
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfigurationTest.java
index 361a43552215..2b447aebad3b 100644
---
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumConfigurationTest.java
@@ -53,7 +53,7 @@ public class EmbeddedDebeziumConfigurationTest {
final TestEmbeddedDebeziumConfiguration configuration = new
TestEmbeddedDebeziumConfiguration();
configuration.setName("test_config");
configuration.setOffsetStorageReplicationFactor(2);
- configuration.setOffsetStorageFileName("/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
// not all required fields being set
assertFalse(configuration.validateConfiguration().isValid());
diff --git
a/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumStorageFilesTest.java
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumStorageFilesTest.java
new file mode 100644
index 000000000000..a3d37205f8ba
--- /dev/null
+++
b/components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/test/java/org/apache/camel/component/debezium/configuration/EmbeddedDebeziumStorageFilesTest.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.debezium.configuration;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+
+/**
+ * The files of the position (the file offset store) and of the schema history
must be writable when the consumer
+ * starts, else every save of the position fails with only a WARN, and a
restart sends everything again.
+ */
+class EmbeddedDebeziumStorageFilesTest {
+
+ private static final String FILE_HISTORY =
"io.debezium.storage.file.history.FileSchemaHistory";
+
+ @TempDir
+ Path dir;
+
+ private static TestEmbeddedDebeziumConfiguration configuration(String
offsetFile) {
+ TestEmbeddedDebeziumConfiguration configuration = new
TestEmbeddedDebeziumConfiguration();
+ configuration.setName("test_config");
+ configuration.setTestField("test_field");
+ configuration.setOffsetStorageFileName(offsetFile);
+ return configuration;
+ }
+
+ @Test
+ void anOffsetFileInAFolderThatExists() throws Exception {
+
assertTrue(configuration(dir.resolve("offsets.dat").toString()).validateConfiguration().isValid());
+
+ // a file that exists already
+ Path file = Files.writeString(dir.resolve("existing.dat"), "");
+
assertTrue(configuration(file.toString()).validateConfiguration().isValid());
+ }
+
+ @Test
+ void anOffsetFileInAFolderThatDoesNotExist() {
+ Path file = dir.resolve("missing/offsets.dat");
+
+ ConfigurationValidation validation =
configuration(file.toString()).validateConfiguration();
+
+ assertFalse(validation.isValid());
+ assertTrue(validation.getReason().contains("offsetStorageFileName (" +
file + ")"), validation.getReason());
+ assertTrue(validation.getReason().contains("which does not exist"),
validation.getReason());
+ }
+
+ @Test
+ void anOffsetFileInAFolderThatCannotBeWritten() throws Exception {
+ Path folder = Files.createDirectory(dir.resolve("read-only"));
+ assumeFalse(!folder.toFile().setWritable(false) ||
Files.isWritable(folder), "the folder stays writable (root)");
+ try {
+ ConfigurationValidation validation
+ =
configuration(folder.resolve("offsets.dat").toString()).validateConfiguration();
+
+ assertFalse(validation.isValid());
+ assertTrue(validation.getReason().contains("which cannot be
written"), validation.getReason());
+ } finally {
+ folder.toFile().setWritable(true);
+ }
+ }
+
+ @Test
+ void anOffsetFileThatIsAFolder() {
+ ConfigurationValidation validation =
configuration(dir.toString()).validateConfiguration();
+
+ assertFalse(validation.isValid());
+ assertTrue(validation.getReason().contains("is a folder"),
validation.getReason());
+ }
+
+ @Test
+ void theOffsetFileOfTheAdditionalPropertiesIsChecked() {
+ // the engine gets the additional properties too
+ TestEmbeddedDebeziumConfiguration configuration =
configuration(dir.resolve("offsets.dat").toString());
+ configuration.setAdditionalProperties(
+ Map.of("offset.storage.file.filename",
dir.resolve("missing/offsets.dat").toString()));
+
+ assertFalse(configuration.validateConfiguration().isValid());
+ }
+
+ @Test
+ void anotherOffsetStoreHasNoFile() {
+ TestEmbeddedDebeziumConfiguration configuration =
configuration(dir.resolve("missing/offsets.dat").toString());
+
configuration.setOffsetStorage("org.apache.kafka.connect.storage.KafkaOffsetBackingStore");
+
+ assertTrue(configuration.validateConfiguration().isValid());
+ }
+
+ @Test
+ void theFileSchemaHistoryCreatesItsFolders() {
+ TestEmbeddedDebeziumConfiguration configuration =
configuration(dir.resolve("offsets.dat").toString());
+
configuration.setAdditionalProperties(Map.of("schema.history.internal",
FILE_HISTORY,
+ "schema.history.internal.file.filename",
dir.resolve("a/b/history.dat").toString()));
+
+ assertTrue(configuration.validateConfiguration().isValid());
+ }
+
+ @Test
+ void theFileSchemaHistoryNeedsAFile() {
+ TestEmbeddedDebeziumConfiguration configuration =
configuration(dir.resolve("offsets.dat").toString());
+
configuration.setAdditionalProperties(Map.of("schema.history.internal",
FILE_HISTORY));
+
+ ConfigurationValidation validation =
configuration.validateConfiguration();
+
+ assertFalse(validation.isValid());
+
assertTrue(validation.getReason().contains("schemaHistoryInternalFileFilename"),
validation.getReason());
+ }
+
+ @Test
+ void theFileSchemaHistoryInAFolderThatCannotBeCreated() throws Exception {
+ Path folder = Files.createDirectory(dir.resolve("read-only"));
+ assumeFalse(!folder.toFile().setWritable(false) ||
Files.isWritable(folder), "the folder stays writable (root)");
+ try {
+ TestEmbeddedDebeziumConfiguration configuration =
configuration(dir.resolve("offsets.dat").toString());
+
configuration.setAdditionalProperties(Map.of("schema.history.internal",
FILE_HISTORY,
+ "schema.history.internal.file.filename",
folder.resolve("a/history.dat").toString()));
+
+ ConfigurationValidation validation =
configuration.validateConfiguration();
+
+ assertFalse(validation.isValid());
+ assertTrue(validation.getReason().contains("cannot be created"),
validation.getReason());
+ } finally {
+ folder.toFile().setWritable(true);
+ }
+ }
+}
diff --git a/components/camel-debezium/camel-debezium-common/pom.xml
b/components/camel-debezium/camel-debezium-common/pom.xml
index d748814f4505..85d3217c85cb 100644
--- a/components/camel-debezium/camel-debezium-common/pom.xml
+++ b/components/camel-debezium/camel-debezium-common/pom.xml
@@ -75,6 +75,12 @@
<artifactId>debezium-storage-file</artifactId>
<version>${debezium-version}</version>
</dependency>
+ <!-- the offset stores of Kafka (file and topic) work through its
OffsetStoreProvider (Kafka 4.x) -->
+ <dependency>
+ <groupId>io.debezium</groupId>
+ <artifactId>debezium-storage-kafka</artifactId>
+ <version>${debezium-version}</version>
+ </dependency>
<dependency>
<groupId>at.yawk.lz4</groupId>
<artifactId>lz4-java</artifactId>
diff --git
a/components/camel-debezium/camel-debezium-db2/src/main/docs/debezium-db2-component.adoc
b/components/camel-debezium/camel-debezium-db2/src/main/docs/debezium-db2-component.adoc
index 694709d2ff5a..bbb52dab3932 100644
---
a/components/camel-debezium/camel-debezium-db2/src/main/docs/debezium-db2-component.adoc
+++
b/components/camel-debezium/camel-debezium-db2/src/main/docs/debezium-db2-component.adoc
@@ -89,6 +89,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -101,7 +116,7 @@ Java::
+
[source,java]
----
-from("debezium-db2:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -116,7 +131,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-db2:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-db2:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -135,12 +150,12 @@ YAML::
from:
uri: debezium-db2:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/DebeziumDb2ComponentTest.java
b/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/DebeziumDb2ComponentTest.java
index b5751b6c8db5..62107f04077b 100644
---
a/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/DebeziumDb2ComponentTest.java
+++
b/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/DebeziumDb2ComponentTest.java
@@ -34,7 +34,7 @@ public class DebeziumDb2ComponentTest {
@Test
void testIfConnectorEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("databaseHostname", "localhost");
params.put("databaseUser", "dbz");
params.put("databasePassword", "pwd");
@@ -43,7 +43,7 @@ public class DebeziumDb2ComponentTest {
params.put("schemaHistoryInternalFileFilename",
"/db_history_file_test");
final String remaining = "test_name";
- final String uri =
"debezium?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium?name=test_name&offsetStorageFileName=target/offset-test&"
+
"databaseHostname=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"topicPrefix=test&schemaHistoryInternalFileFilename=/test";
@@ -57,7 +57,7 @@ public class DebeziumDb2ComponentTest {
final Db2ConnectorEmbeddedDebeziumConfiguration configuration
= (Db2ConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("dbz", configuration.getDatabaseUser());
assertEquals("pwd", configuration.getDatabasePassword());
@@ -73,7 +73,7 @@ public class DebeziumDb2ComponentTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setDatabasePassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/db2/configuration/Db2ConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/db2/configuration/Db2ConnectorEmbeddedDebeziumConfigurationTest.java
index 10606c278d73..d5a9b6683f05 100644
---
a/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/db2/configuration/Db2ConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-db2/src/test/java/org/apache/camel/component/debezium/db2/configuration/Db2ConnectorEmbeddedDebeziumConfigurationTest.java
@@ -58,7 +58,7 @@ public class Db2ConnectorEmbeddedDebeziumConfigurationTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -78,7 +78,7 @@ public class Db2ConnectorEmbeddedDebeziumConfigurationTest {
configuration.setDatabaseHostname("localhost");
configuration.setDatabasePassword("test_pwd");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -89,7 +89,7 @@ public class Db2ConnectorEmbeddedDebeziumConfigurationTest {
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("test_pwd", configuration.getDatabasePassword());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/components/camel-debezium/camel-debezium-mongodb/src/main/docs/debezium-mongodb-component.adoc
b/components/camel-debezium/camel-debezium-mongodb/src/main/docs/debezium-mongodb-component.adoc
index dbcbbfb31b9d..a29c8d3b54dc 100644
---
a/components/camel-debezium/camel-debezium-mongodb/src/main/docs/debezium-mongodb-component.adoc
+++
b/components/camel-debezium/camel-debezium-mongodb/src/main/docs/debezium-mongodb-component.adoc
@@ -99,6 +99,18 @@ then set only when the transformation adds the operation,
with `additionalProper
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -111,7 +123,7 @@ Java::
+
[source,java]
----
-from("debezium-mongodb:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -131,7 +143,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-mongodb:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-mongodb:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&mongodbConnectionString=RAW(mongodb://localhost:27017/?replicaSet=rs0)&mongodbUser=debezium&mongodbPassword=dbz&topicPrefix=dbserver1&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -156,12 +168,12 @@ YAML::
from:
uri: debezium-mongodb:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
mongodbConnectionString: "mongodb://localhost:27017/?replicaSet=rs0"
mongodbUser: debezium
mongodbPassword: dbz
topicPrefix: dbserver1
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/DebeziumMongodbComponentTest.java
b/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/DebeziumMongodbComponentTest.java
index 49b3b02eb505..c8e7d13e67e9 100644
---
a/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/DebeziumMongodbComponentTest.java
+++
b/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/DebeziumMongodbComponentTest.java
@@ -33,7 +33,7 @@ public class DebeziumMongodbComponentTest {
@Test
void testIfConnectorEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("mongodbConnectionString",
"mongodb://localhost:27017/?replicaSet=rs0");
params.put("mongodbUser", "dbz");
params.put("mongodbPassword", "pwd");
@@ -41,7 +41,7 @@ public class DebeziumMongodbComponentTest {
params.put("schemaHistoryInternalFileFilename",
"/db_history_file_test");
final String remaining = "test_name";
- final String uri =
"debezium?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium?name=test_name&offsetStorageFileName=target/offset-test&"
+
"databaseHostname=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"databaseServerName=test&schemaHistoryInternalFileFilename=/test";
@@ -55,7 +55,7 @@ public class DebeziumMongodbComponentTest {
final MongoDbConnectorEmbeddedDebeziumConfiguration configuration
= (MongoDbConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("mongodb://localhost:27017/?replicaSet=rs0",
configuration.getMongodbConnectionString());
assertEquals("dbz", configuration.getMongodbUser());
assertEquals("pwd", configuration.getMongodbPassword());
@@ -70,7 +70,7 @@ public class DebeziumMongodbComponentTest {
configuration.setName("test_config");
configuration.setMongodbUser("test_db");
configuration.setMongodbPassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/mongodb/configuration/MongodbConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/mongodb/configuration/MongodbConnectorEmbeddedDebeziumConfigurationTest.java
index b484b70229c8..804cc8011310 100644
---
a/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/mongodb/configuration/MongodbConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-mongodb/src/test/java/org/apache/camel/component/debezium/mongodb/configuration/MongodbConnectorEmbeddedDebeziumConfigurationTest.java
@@ -55,7 +55,7 @@ public class
MongodbConnectorEmbeddedDebeziumConfigurationTest {
configuration.setName("test_config");
configuration.setMongodbUser("test_db");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -74,7 +74,7 @@ public class
MongodbConnectorEmbeddedDebeziumConfigurationTest {
configuration.setMongodbConnectionString("mongodb://localhost:27017/?replicaSet=rs0");
configuration.setMongodbPassword("test_pwd");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -85,7 +85,7 @@ public class
MongodbConnectorEmbeddedDebeziumConfigurationTest {
assertEquals("mongodb://localhost:27017/?replicaSet=rs0",
configuration.getMongodbConnectionString());
assertEquals("test_pwd", configuration.getMongodbPassword());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/components/camel-debezium/camel-debezium-mysql/src/main/docs/debezium-mysql-component.adoc
b/components/camel-debezium/camel-debezium-mysql/src/main/docs/debezium-mysql-component.adoc
index ff87d1557167..8f3db6306db0 100644
---
a/components/camel-debezium/camel-debezium-mysql/src/main/docs/debezium-mysql-component.adoc
+++
b/components/camel-debezium/camel-debezium-mysql/src/main/docs/debezium-mysql-component.adoc
@@ -100,6 +100,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -112,7 +127,7 @@ Java::
+
[source,java]
----
-from("debezium-mysql:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-mysql:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -128,7 +143,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-mysql:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-mysql:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -148,12 +163,12 @@ YAML::
from:
uri: debezium-mysql:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/DebeziumMySqlComponentTest.java
b/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/DebeziumMySqlComponentTest.java
index 4d68153a3177..d75533014eaf 100644
---
a/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/DebeziumMySqlComponentTest.java
+++
b/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/DebeziumMySqlComponentTest.java
@@ -33,7 +33,7 @@ public class DebeziumMySqlComponentTest {
@Test
void testIfMySqlEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("databaseHostname", "localhost");
params.put("databaseUser", "dbz");
params.put("databasePassword", "pwd");
@@ -43,7 +43,7 @@ public class DebeziumMySqlComponentTest {
params.put("additionalProperties.database.connectionTimeZone", "CET");
final String remaining = "test_name";
- final String uri =
"debezium:mysql?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium:mysql?name=test_name&offsetStorageFileName=target/offset-test&"
+
"topicPrefix=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"databaseServerName=test&schemaHistoryInternalFileFilename=/test";
@@ -57,7 +57,7 @@ public class DebeziumMySqlComponentTest {
final MySqlConnectorEmbeddedDebeziumConfiguration configuration
= (MySqlConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("dbz", configuration.getDatabaseUser());
assertEquals("pwd", configuration.getDatabasePassword());
@@ -74,7 +74,7 @@ public class DebeziumMySqlComponentTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setDatabasePassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/mysql/configuration/MySqlConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/mysql/configuration/MySqlConnectorEmbeddedDebeziumConfigurationTest.java
index 01ea7b887159..2200842d195b 100644
---
a/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/mysql/configuration/MySqlConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-mysql/src/test/java/org/apache/camel/component/debezium/mysql/configuration/MySqlConnectorEmbeddedDebeziumConfigurationTest.java
@@ -63,7 +63,7 @@ public class MySqlConnectorEmbeddedDebeziumConfigurationTest {
configuration.setDatabaseUser("test_db");
configuration.setDatabaseServerId(123);
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternal("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -83,7 +83,7 @@ public class MySqlConnectorEmbeddedDebeziumConfigurationTest {
configuration.setDatabasePassword("test_pwd");
configuration.setDatabaseServerId(123);
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -95,7 +95,7 @@ public class MySqlConnectorEmbeddedDebeziumConfigurationTest {
assertEquals("test_pwd", configuration.getDatabasePassword());
assertEquals(123, configuration.getDatabaseServerId());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/components/camel-debezium/camel-debezium-oracle/src/main/docs/debezium-oracle-component.adoc
b/components/camel-debezium/camel-debezium-oracle/src/main/docs/debezium-oracle-component.adoc
index d2555e6dcf69..1176215fd839 100644
---
a/components/camel-debezium/camel-debezium-oracle/src/main/docs/debezium-oracle-component.adoc
+++
b/components/camel-debezium/camel-debezium-oracle/src/main/docs/debezium-oracle-component.adoc
@@ -87,6 +87,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -99,7 +114,7 @@ Java::
+
[source,java]
----
-from("debezium-oracle:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-oracle:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -114,7 +129,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-oracle:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-oracle:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -133,12 +148,12 @@ YAML::
from:
uri: debezium-oracle:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/DebeziumOracleComponentTest.java
b/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/DebeziumOracleComponentTest.java
index bf7b2a6813f4..4ef63f98c926 100644
---
a/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/DebeziumOracleComponentTest.java
+++
b/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/DebeziumOracleComponentTest.java
@@ -34,7 +34,7 @@ public class DebeziumOracleComponentTest {
@Test
void testIfConnectorEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("databaseHostname", "localhost");
params.put("databaseUser", "dbz");
params.put("databasePassword", "pwd");
@@ -43,7 +43,7 @@ public class DebeziumOracleComponentTest {
params.put("schemaHistoryInternalFileFilename",
"/db_history_file_test");
final String remaining = "test_name";
- final String uri =
"debezium?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium?name=test_name&offsetStorageFileName=target/offset-test&"
+
"topicPrefix=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"databaseServerName=test&schemaHistoryInternalFileFilename=/test";
@@ -57,7 +57,7 @@ public class DebeziumOracleComponentTest {
final OracleConnectorEmbeddedDebeziumConfiguration configuration
= (OracleConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("dbz", configuration.getDatabaseUser());
assertEquals("pwd", configuration.getDatabasePassword());
@@ -73,7 +73,7 @@ public class DebeziumOracleComponentTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setDatabasePassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/oracle/configuration/OracleConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/oracle/configuration/OracleConnectorEmbeddedDebeziumConfigurationTest.java
index 423be2e5d0f5..2a24dd352c6a 100644
---
a/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/oracle/configuration/OracleConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-oracle/src/test/java/org/apache/camel/component/debezium/oracle/configuration/OracleConnectorEmbeddedDebeziumConfigurationTest.java
@@ -58,7 +58,7 @@ public class OracleConnectorEmbeddedDebeziumConfigurationTest
{
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -78,7 +78,7 @@ public class OracleConnectorEmbeddedDebeziumConfigurationTest
{
configuration.setDatabaseHostname("localhost");
configuration.setDatabasePassword("test_pwd");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -89,7 +89,7 @@ public class OracleConnectorEmbeddedDebeziumConfigurationTest
{
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("test_pwd", configuration.getDatabasePassword());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/components/camel-debezium/camel-debezium-postgres/src/main/docs/debezium-postgres-component.adoc
b/components/camel-debezium/camel-debezium-postgres/src/main/docs/debezium-postgres-component.adoc
index 0f7e6e9de9a6..288385b57d43 100644
---
a/components/camel-debezium/camel-debezium-postgres/src/main/docs/debezium-postgres-component.adoc
+++
b/components/camel-debezium/camel-debezium-postgres/src/main/docs/debezium-postgres-component.adoc
@@ -87,6 +87,18 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -99,7 +111,7 @@ Java::
+
[source,java]
----
-from("debezium-postgres:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-postgres:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -114,7 +126,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-postgres:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-postgres:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -133,12 +145,12 @@ YAML::
from:
uri: debezium-postgres:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/DebeziumPostgresComponentTest.java
b/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/DebeziumPostgresComponentTest.java
index 2097ea699a83..9d553d716772 100644
---
a/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/DebeziumPostgresComponentTest.java
+++
b/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/DebeziumPostgresComponentTest.java
@@ -33,7 +33,7 @@ public class DebeziumPostgresComponentTest {
@Test
void testIfConnectorEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("databaseHostname", "localhost");
params.put("databaseUser", "dbz");
params.put("databasePassword", "pwd");
@@ -42,7 +42,7 @@ public class DebeziumPostgresComponentTest {
params.put("schemaHistoryInternalFileFilename",
"/db_history_file_test");
final String remaining = "test_name";
- final String uri =
"debezium?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium?name=test_name&offsetStorageFileName=target/offset-test&"
+
"databaseHostname=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"topicPrefix=test&schemaHistoryInternalFileFilename=/test";
@@ -56,7 +56,7 @@ public class DebeziumPostgresComponentTest {
final PostgresConnectorEmbeddedDebeziumConfiguration configuration
= (PostgresConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("dbz", configuration.getDatabaseUser());
assertEquals("pwd", configuration.getDatabasePassword());
@@ -72,7 +72,7 @@ public class DebeziumPostgresComponentTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setDatabasePassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/postgres/configuration/PostgresConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/postgres/configuration/PostgresConnectorEmbeddedDebeziumConfigurationTest.java
index 0b9fcd5e429b..c042e9e97b8f 100644
---
a/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/postgres/configuration/PostgresConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-postgres/src/test/java/org/apache/camel/component/debezium/postgres/configuration/PostgresConnectorEmbeddedDebeziumConfigurationTest.java
@@ -57,7 +57,7 @@ public class
PostgresConnectorEmbeddedDebeziumConfigurationTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -77,7 +77,7 @@ public class
PostgresConnectorEmbeddedDebeziumConfigurationTest {
configuration.setDatabaseHostname("localhost");
configuration.setDatabasePassword("test_pwd");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -88,7 +88,7 @@ public class
PostgresConnectorEmbeddedDebeziumConfigurationTest {
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("test_pwd", configuration.getDatabasePassword());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/components/camel-debezium/camel-debezium-sqlserver/src/main/docs/debezium-sqlserver-component.adoc
b/components/camel-debezium/camel-debezium-sqlserver/src/main/docs/debezium-sqlserver-component.adoc
index 43913d21386c..9f11c676af6a 100644
---
a/components/camel-debezium/camel-debezium-sqlserver/src/main/docs/debezium-sqlserver-component.adoc
+++
b/components/camel-debezium/camel-debezium-sqlserver/src/main/docs/debezium-sqlserver-component.adoc
@@ -85,6 +85,21 @@ transformation adds the operation, with
`additionalProperties.transforms.unwrap.
See below for more details.
+== Where the position is saved
+
+Debezium saves how far the connector got, so that after a restart it goes on
from there. With the default
+`offsetStorage` (`org.apache.kafka.connect.storage.FileOffsetBackingStore`),
the position is saved to the file of
+`offsetStorageFileName`. The file is created when it does not exist, but its
folder must exist and be writable: the
+consumer fails when it starts otherwise, as without it nothing is saved and a
restart sends everything again, the
+snapshot included. A relative name is in the folder the integration runs in,
such as `data/offset-file-1.dat`.
+
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file of
+`schemaHistoryInternalFileFilename` is checked as well; Debezium creates its
folders when they do not exist.
+
+To save the position in a Kafka topic instead, such as for an integration that
has no lasting disk, set `offsetStorage`
+to `org.apache.kafka.connect.storage.KafkaOffsetBackingStore`, with
`offsetStorageTopic`, `offsetStoragePartitions`,
+`offsetStorageReplicationFactor` and the Kafka brokers as
`additionalProperties.bootstrap.servers`.
+
== Examples
=== Consuming events
@@ -97,7 +112,7 @@ Java::
+
[source,java]
----
-from("debezium-sqlserver:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat")
+from("debezium-sqlserver:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat")
.log("Event received from Debezium : ${body}")
.log(" with this identifier ${headers.CamelDebeziumIdentifier}")
.log(" with these source metadata
${headers.CamelDebeziumSourceMetadata}")
@@ -112,7 +127,7 @@ XML::
[source,xml]
----
<route>
- <from
uri="debezium-sqlserver:dbz-test-1?offsetStorageFileName=/usr/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=/usr/history-file-1.dat"/>
+ <from
uri="debezium-sqlserver:dbz-test-1?offsetStorageFileName=data/offset-file-1.dat&databaseHostname=localhost&databaseUser=debezium&databasePassword=dbz&topicPrefix=my-app-connector&schemaHistoryInternalFileFilename=data/history-file-1.dat"/>
<log message="Event received from Debezium : ${body}"/>
<log message=" with this identifier ${headers.CamelDebeziumIdentifier}"/>
<log message=" with these source metadata
${headers.CamelDebeziumSourceMetadata}"/>
@@ -131,12 +146,12 @@ YAML::
from:
uri: debezium-sqlserver:dbz-test-1
parameters:
- offsetStorageFileName: /usr/offset-file-1.dat
+ offsetStorageFileName: data/offset-file-1.dat
databaseHostname: localhost
databaseUser: debezium
databasePassword: dbz
topicPrefix: my-app-connector
- schemaHistoryInternalFileFilename: /usr/history-file-1.dat
+ schemaHistoryInternalFileFilename: data/history-file-1.dat
steps:
- log:
message: "Event received from Debezium : ${body}"
diff --git
a/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/DebeziumSqlserverComponentTest.java
b/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/DebeziumSqlserverComponentTest.java
index acc483a2693c..d64e02ab1013 100644
---
a/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/DebeziumSqlserverComponentTest.java
+++
b/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/DebeziumSqlserverComponentTest.java
@@ -33,7 +33,7 @@ public class DebeziumSqlserverComponentTest {
@Test
void testIfConnectorEndpointCreatedWithConfig() throws Exception {
final Map<String, Object> params = new HashMap<>();
- params.put("offsetStorageFileName", "/offset_test_file");
+ params.put("offsetStorageFileName", "target/offset_test_file");
params.put("databaseHostname", "localhost");
params.put("databaseUser", "dbz");
params.put("databasePassword", "pwd");
@@ -42,7 +42,7 @@ public class DebeziumSqlserverComponentTest {
params.put("schemaHistoryInternalFileFilename",
"/db_history_file_test");
final String remaining = "test_name";
- final String uri =
"debezium?name=test_name&offsetStorageFileName=/test&"
+ final String uri =
"debezium?name=test_name&offsetStorageFileName=target/offset-test&"
+
"databaseHostname=localhost&databaseServerId=1234&databaseUser=dbz&databasePassword=pwd&"
+
"topicPrefix=test&schemaHistoryInternalFileFilename=/test";
@@ -56,7 +56,7 @@ public class DebeziumSqlserverComponentTest {
final SqlServerConnectorEmbeddedDebeziumConfiguration configuration
= (SqlServerConnectorEmbeddedDebeziumConfiguration)
debeziumEndpoint.getConfiguration();
assertEquals("test_name", configuration.getName());
- assertEquals("/offset_test_file",
configuration.getOffsetStorageFileName());
+ assertEquals("target/offset_test_file",
configuration.getOffsetStorageFileName());
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("dbz", configuration.getDatabaseUser());
assertEquals("pwd", configuration.getDatabasePassword());
@@ -72,7 +72,7 @@ public class DebeziumSqlserverComponentTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setDatabasePassword("pwd");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setTopicPrefix("test");
final String uri = "debezium:dummy";
diff --git
a/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/sqlserver/configuration/SqlserverConnectorEmbeddedDebeziumConfigurationTest.java
b/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/sqlserver/configuration/SqlserverConnectorEmbeddedDebeziumConfigurationTest.java
index 40c629845c58..5abe19cc0686 100644
---
a/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/sqlserver/configuration/SqlserverConnectorEmbeddedDebeziumConfigurationTest.java
+++
b/components/camel-debezium/camel-debezium-sqlserver/src/test/java/org/apache/camel/component/debezium/sqlserver/configuration/SqlserverConnectorEmbeddedDebeziumConfigurationTest.java
@@ -56,7 +56,7 @@ public class
SqlserverConnectorEmbeddedDebeziumConfigurationTest {
configuration.setName("test_config");
configuration.setDatabaseUser("test_db");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
assertFalse(configuration.validateConfiguration().isValid());
@@ -76,7 +76,7 @@ public class
SqlserverConnectorEmbeddedDebeziumConfigurationTest {
configuration.setDatabaseHostname("localhost");
configuration.setDatabasePassword("test_pwd");
configuration.setTopicPrefix("test_server");
- configuration.setOffsetStorageFileName("/offset/file");
+ configuration.setOffsetStorageFileName("target/offset-file");
configuration.setSchemaHistoryInternalFileFilename("/database_history/file");
final ConfigurationValidation validation =
configuration.validateConfiguration();
@@ -87,7 +87,7 @@ public class
SqlserverConnectorEmbeddedDebeziumConfigurationTest {
assertEquals("localhost", configuration.getDatabaseHostname());
assertEquals("test_pwd", configuration.getDatabasePassword());
assertEquals("test_server", configuration.getTopicPrefix());
- assertEquals("/offset/file", configuration.getOffsetStorageFileName());
+ assertEquals("target/offset-file",
configuration.getOffsetStorageFileName());
assertEquals("/database_history/file",
configuration.getSchemaHistoryInternalFileFilename());
}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 8461eb0c093a..ab7ffaa77332 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -3894,6 +3894,19 @@ changed fields of an update are now in the new
`CamelDebeziumUpdateDescription`
The `Struct` to `Map` type converter now also converts a `Struct` inside a
list or a map.
+=== camel-debezium - the folder of the offset file must exist, and the Map
keeps the order of the columns
+
+With the default file offset store, a `debezium-*` endpoint now fails to start
when the folder of
+`offsetStorageFileName` does not exist or cannot be written, or when the file
exists and cannot be written. The error
+names the file. Before, the consumer started, every save of its position
failed with only a WARN in the log, and after
+a restart everything was sent again, the snapshot included. Create the folder,
or use a file in a folder that exists.
+With the file schema history
(`schemaHistoryInternal=io.debezium.storage.file.history.FileSchemaHistory`),
the file
+of `schemaHistoryInternalFileFilename` must be writable too; its folders may
be missing, as Debezium creates them.
+
+The `Struct` to `Map` type converter now gives a `LinkedHashMap` in the order
of the fields of the `Struct` (the order
+of the columns of the table), nested `Struct` values included, so the JSON of
the `Map` has the columns in that order.
+Before, it was a `HashMap` with no defined order.
+
=== camel-debezium-mysql - a signed TINYINT column is a Byte
Debezium has been upgraded to 3.7.0.Final, which maps a signed MySQL `TINYINT`
column to the Kafka Connect `INT8`