DBZ-6723 Expose partition number in ChangeEvent interface

Based on feedback in https://github.com/debezium/debezium-server/pull/33 this
commit adds the partition() method to the ChangeEvent interface and implements
it in the EmbeddedEngineChangeEvent. This allows reading the assigned partition
for an event in downstream processors, for example in custom Sinks that need
the assigned partition for routing purposes.

Link:  https://issues.redhat.com/browse/DBZ-6723
This commit is contained in:
Sebastiaan Knijnenburg 2023-11-22 10:22:05 +01:00 committed by Jiri Pechanec
parent 0ff0ff54ae
commit 036eda0c64
3 changed files with 19 additions and 0 deletions

View File

@ -28,4 +28,9 @@ default <H> List<Header<H>> headers() {
* @return A name of the logical destination for which the event is intended
*/
String destination();
/**
* @return The partition number for the event. Can be null.
*/
Integer partition();
}

View File

@ -53,6 +53,11 @@ public String destination() {
return sourceRecord.topic();
}
@Override
public Integer partition() {
return sourceRecord.kafkaPartition();
}
public SourceRecord sourceRecord() {
return sourceRecord;
}

View File

@ -9,6 +9,15 @@
</item>
</revapi.ignore>
</version-1.5.0>
<version-2.5.0>
<revapi.ignore>
<item>
<code>java.method.addedToInterface</code>
<class>io.debezium.engine.ChangeEvent</class>
<justification>This interface is not supposed to be implemented by clients.</justification>
</item>
</revapi.ignore>
</version-2.5.0>
<!-- No changes as of yet. This is just an example of how to tell Revapi to ignore intentional changes.
<version-1.2.0>
<revapi.ignore>