Search code examples
spring-bootspring-integrationamazon-kinesisspring-cloud-streamspring-integration-aws

Creating Kinesis consumers based on configuration


I would like develop a consumer library which would read kinesis stream names from spring properties file and create/activate associated consumers.

In all the examples I have seen (like https://github.com/spring-cloud/spring-cloud-stream-samples/blob/master/kinesis-samples/kinesis-produce-consume/src/main/java/demo/stream/OrderStreamConfiguration.java), consumers are annotation-based and they should be manually defined.

I want to know which class from spring-integration/spring-aws-kinesis library I could use to generically create consumers.

Thank you


Solution

  • For dynamic and runtime purpose we suggest to use Spring Integration Java DSL and its IntegrationFlowContext: https://docs.spring.io/spring-integration/docs/5.0.5.RELEASE/reference/html/java-dsl.html#java-dsl-runtime-flows.

    So, what you mean could be achieved with an iterator over those properties and an

    KinesisMessageDrivenChannelAdapter kinesisMessageDrivenChannelAdapter = ...;
    IntegrationFlows.from(kinesisMessageDrivenChannelAdapter)... ;
    

    combination.