EricJoy2048 commented on code in PR #3085:
URL:
https://github.com/apache/incubator-seatunnel/pull/3085#discussion_r995309605
##########
seatunnel-connectors-v2/connector-kafka/src/main/java/org/apache/seatunnel/connectors/seatunnel/kafka/serialize/DefaultSeaTunnelRowSerializer.java:
##########
@@ -48,4 +48,10 @@ public ProducerRecord<byte[], byte[]>
serializeRow(SeaTunnelRow row) {
return new ProducerRecord<>(topic, null,
jsonSerializationSchema.serialize(row));
}
}
+
+ @Override
+ public ProducerRecord<byte[], byte[]> serializeRowByKey(String key,
SeaTunnelRow row) {
+ return new ProducerRecord<>(topic, key.getBytes(),
jsonSerializationSchema.serialize(row));
Review Comment:
> check key is null?
I think we don not need check `key` is null, because if the `key` is null,
kafka will send it to a random partition(random select a new partition per
`topic.metadata.refresh.ms`).
```
The third property "partitioner.class" defines what class to use to
determine which Partition in the Topic the message is to be sent to. This is
optional, but for any non-trivial implementation you are going to want to
implement a partitioning scheme. More about the implementation of this class
later. If you include a value for the key but haven't defined a
partitioner.class Kafka will use the default partitioner. If the key is null,
then the Producer will assign the message to a random Partition.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]