apache kafka – Get topic name from Spring Cloud Stream MessageChannel

We are using Kafka Cloud Stream in a Spring Boot application to send data to Kafka.
like this

producerChannel.send(MessageBuilder
                    .withPayload(data)
                    .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
                    .build())

I would like to know whether it’s possible to get topic name from the MessageChannel, other than reading directly from yaml file?

@Output("topic-name-out")
MessageChannel producerChannel();

Topic name is present in a kafka.yaml

spring:
  cloud:
    stream:
      bindings:
        topic-name-out:
          destination: topic_name_to_producer
          contentType: application/json
          producer:
            partitionCount: ${partition_count:3}

Read more here: Source link