Dynamic Value for recordKey in Send-Event Task

.event File

  "key": "sessionEvent",
  "outboundChannelKeys": [
  "correlationParameters": [],
  "payload": [
      "name": "sessionId",
      "type": "string"

.channel File

  "key": "sessionOutboundChannel",
  "channelType": "outbound",
  "type": "kafka",
  "serializerType": "json",
  "topic": "SESSIONS",
  "recordKey": "sessionId"

with the above configuration with (recordKey)
I can see plain text sessionId is coming as message key in Kafka.

  1. Is there a way to pass the dynamic String value of sessionId prop from the payload as a message key?

  2. Is it also possible to send JSON value as a message key?

Assuming SpEL may work, I tried using variables namespace as below, but no luck, it’s coming as plain text.

"recordKey": "${var:get('sessionId')}"

Below is the screenshot from a stream backed by that topic SESSIONS.
Screen Shot 2020-07-04 at 6.34.53 PM

SpEL won’t work, even juel (which is used in Flowable as expression language) won’t work here, because the channel is static. The problem is that the channel needs to be deployed beforehand right now, to be used and it’s not bound to the instance level, but engine level (hence why variables are not available).

So am I getting you right that you want to dynamically send to a topic, but the recordKey needs to change?

Hi @joram
Got you on SpEL, JUEL.
Yes. If the purpose of recordKey prop is for Message Key in Kafka (my usecase), yes bare minimum I wanted to send dynamic String value. Also for greater flexibility, I want to explore dynamic JSON value.

From your explanation of “static nature of channel file”, I feel the right place of recordKey prop is event file.

Do you need any info from me?

Hi @filiphr

Any insights on this?

Thank you.

I do think, if I understand your use case correctly, that it’s a new feature that’s currently not there. It would mean an addition step in the channel that’s currently not there.