# Option to update KEY value in the messages pulled using MQTT Source Connector for Kafka

**URL:** <https://ask.lenses.io/t/option-to-update-key-value-in-the-messages-pulled-using-mqtt-source-connector-for-kafka/480>\
**Category:** Apache Kafka Connectors\
**Created:** [May 11, 2026, 5:09pm UTC](https://ask.lenses.io/t/option-to-update-key-value-in-the-messages-pulled-using-mqtt-source-connector-for-kafka/480 "2026-05-11T17:09:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noeltoms](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@noeltoms](https://ask.lenses.io/u/noeltoms)\
**Post date:** [May 11, 2026, 5:09pm UTC](https://ask.lenses.io/t/option-to-update-key-value-in-the-messages-pulled-using-mqtt-source-connector-for-kafka/480/1 "2026-05-11T17:09:41Z")

</div>

I am using MQTT Source Connector to pull MQTT messages from an external broker to my AWS MSK Kafka. My Kafka topic has 6 partitions, but all the messages are going to one single partition. On checking the messages received, I realized that the MQTT connector is by default setting the KEY value and this is a constant which makes kafka to push all messages to just 1 partition. Is there a way to edit the KEY value pre-set by the MQTT Connector to a random value or at the least to make it NULL.

---

<div class="post-metadata">

**Author:** ![Andrew\_Stevenson](https://dub1.discourse-cdn.com/flex017/user_avatar/ask.lenses.io/andrew_stevenson/32/80_2.png) [@Andrew\_Stevenson](https://ask.lenses.io/u/Andrew_Stevenson)\
**Post date:** [May 12, 2026, 9:09am UTC](https://ask.lenses.io/t/option-to-update-key-value-in-the-messages-pulled-using-mqtt-source-connector-for-kafka/480/2 "2026-05-12T09:09:39Z")

</div>

@noeltoms You can use an SMT to update the key value. Connect will pass it through them before its written to Kafka. Or you can use [MQTT | Kafka Connectors | Lenses Docs](https://docs.lenses.io/latest/connectors/kafka-connectors/sources/mqtt#keyed-json-format)

email us at [info@lenses.io](mailto:info@lenses.io) and we can discuss.
