HiveMQ MQTT-To-Kafka key

Hi,

How do I set the key of the a kafka record in a mqtt-to-kafka-mapping in the configuration file?

I want to set the mqtt-clientid as the key in the target kafka records.

Hello @mhx,

We’re delighted to welcome you to the HiveMQ Community! Your interest in MQTT and the HiveMQ broker is fantastic, and we’re excited to have you on board.

Thank you for reaching out to us.

Regarding the mqtt-to-kafka-mapping, it’s important to note that the MQTT Topic functions as the Kafka Key, and the MQTT Payload serves as the Kafka Value. These mappings are set and cannot be directly modified.

If you’re keen on customizing the Kafka key, you’ll need to leverage your Java skills. You can achieve this by implementing a MQTT-to-Kafka Transformer. Detailed information and guidelines are available in the official documentation: HiveMQ Kafka Extension - MQTT-to-Kafka Transformer.

I trust this information proves helpful. Should you have any additional questions or require further clarification, feel free to reach out.

Best regards,
Dasha from HiveMQ Team