TaoZex commented on code in PR #3085:
URL:
https://github.com/apache/incubator-seatunnel/pull/3085#discussion_r996638635
##########
seatunnel-connectors-v2/connector-kafka/src/main/java/org/apache/seatunnel/connectors/seatunnel/kafka/sink/KafkaSinkWriter.java:
##########
@@ -63,7 +66,22 @@ public class KafkaSinkWriter implements
SinkWriter<SeaTunnelRow, KafkaCommitInfo
// check config
@Override
public void write(SeaTunnelRow element) {
- ProducerRecord<byte[], byte[]> producerRecord =
seaTunnelRowSerializer.serializeRow(element);
+ ProducerRecord<byte[], byte[]> producerRecord = null;
+ //Determine the partition of the kafka send message based on the field
name
+ if (pluginConfig.hasPath(PARTITION_KEY)){
+ String keyField = pluginConfig.getString(PARTITION_KEY);
+ List<String> fields =
Arrays.asList(seaTunnelRowType.getFieldNames());
+ String key;
+ if (fields.contains(keyField)) {
+ key = element.getField(fields.indexOf(keyField)).toString();
+ } else {
+ key = keyField;
+ }
Review Comment:
Thanks to @EricJoy2048 and @hailin0 the good suggestion, I will fix it.
--
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]