Search code examples
spring-cloud-stream

Spring Cloud Stream kafka producer, producing to dynamic kafka topic


I would like to create a kafka endpoint using spring cloud stream framework, which will have a http post api to /{topic_name}.How can I dynamically change spring.cloud.stream.bindings.<channelName>.destination={topic_name} property

I could use confluent Kafka REST Proxy implementation to achieve above functionality, but wondering if its possible to develop this in spring.


Solution

  • Here is a sample that demonstrates these types of use cases where it uses dynamic destinations based on an http trigger. Take a look at the code and the README.

    https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/source-samples/dynamic-destination-source-kafka