# Static Message Key JDBC Source Connector

**URL:** <https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832>\
**Category:** Kafka Connect\
**Created:** [20 May 2021 10:29 UTC](https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832 "2021-05-20T10:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [20 May 2021 10:29 UTC](https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832/1 "2021-05-20T10:29:38Z")

</div>

Hi,

is it possible to set a static message key?  
I only see an example for a dynamic message key like this;

```auto
"transforms":"createKey,extractInt",
"transforms.createKey.type":"org.apache.kafka.connect.transforms.ValueToKey",
"transforms.createKey.fields":"id",
"transforms.extractInt.type":"org.apache.kafka.connect.transforms.ExtractField$Key",
"transforms.extractInt.field":"id"

```

I only want that:

```auto
"transforms":"createKey",
"transforms.createKey.type":"org.apache.kafka.connect.transforms.ValueToKey",
"transforms.createKey.fields":"SaticKeyValue",

```

Tahnks for help.

Regards,

Marcel

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [20 May 2021 12:32 UTC](https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832/2 "2021-05-20T12:32:44Z")

</div>

I think you can use [org.apache.kafka.connect.transforms.InsertField$Key](https://docs.confluent.io/platform/current/connect/transforms/insertfield.html) to do this.

Just a thought, if you’re setting the same key for every single message though is there much point?

---

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [20 May 2021 12:50 UTC](https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832/3 "2021-05-20T12:50:31Z")

</div>

Ok, that is what i am looking for thx Robin.

---

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [21 May 2021 05:56 UTC](https://forum.confluent.io/t/static-message-key-jdbc-source-connector/1832/4 "2021-05-21T05:56:46Z")

</div>

@rmoff  
Hi Robin maybe you can help me again.  
I try this:

```auto
"transforms.insertKey.type": "org.apache.kafka.connect.transforms.InsertField$Key",
"transforms.insertKey.static.field": "MessageSource",
"transforms.insertKey.static.value": "Database"

```

But the message Key is still null. Any Ideas?
