oscerd commented on issue #1553:
URL: 
https://github.com/apache/camel-kafka-connector/issues/1553#issuecomment-6632216437

   Sorry nobody got back to you on this. The sink task does not pass the record 
key to the target producer by itself: it stores it in the Camel header 
`camel.kafka.connector.record.key`, while the Kafka sink Kamelet only sets the 
outgoing key from a `key` (or `ce-key`) header. kafka-not-secured-sink was 
replaced in 4.18.0 by camel-kafka-sink-kafka-connector 
(`org.apache.camel.kafkaconnector.kafkasink.CamelKafkasinkSinkConnector`), 
where you can copy the key into that header with the FieldsToHeaders SMT 
(https://camel.apache.org/camel-kafka-connector/next/reference/transformers/fieldsToHeaders.html):
 `transforms=keyToHeader`, 
`transforms.keyToHeader.type=org.apache.camel.kafkaconnector.transforms.FieldsToHeadersTransform$Key`,
 `transforms.keyToHeader.headers=CamelHeader.key`. With `ByteArrayConverter` it 
is also worth setting 
`camel.component.kafka.valueSerializer=org.apache.kafka.common.serialization.ByteArraySerializer`
 (and `keySerializer` for binary keys), because the producer oth
 erwise converts to String; in a quick check with the 4.22.0 jars, the key 
reached the target record with the SMT and was null without it. Closing this as 
a usage question; if keys are still missing on 4.22.x, please open a new issue 
with the version and connector config.
   
   ---
   _Claude Code on behalf of Andrea Cosentino_


-- 
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]

Reply via email to