spring-bootspring-cloud-streamamazon-kinesis

Amazon Kinesis Stream name is not taken as per provided application.yml file


I have a spring boot application that used Amazon Kinesis to consume data. Its taking wrong Stream name my actual name that need to use is:"test-test.tst.v1"

but its using :"kinesisConsumer-in-o"

Using below dependency in my project implementation 'org.springframework.cloud:spring-cloud-stream-binder-kinesis:4.0.2'

my application.yml file

spring:
  cloud:
    aws:
      credentials:
        sts:
          web-identity-token-file: <Where i had given the token file path>
          role-arn: <Where i had given the assume role arn>
          role-session-name: AssumedRoleSession
      region:
        static: <where i had given my aws region>
      dualstack-enabled: false
    stream:
      kinesis:
        binder:
          auto-create-stream: false
          min-shard-count: 1
      bindings:
        input-in-0:
          destination: test-test.tst.v1
          content-type: text/json
    function:
      definition: kinesisConsumer

Below is the java class which contain the bean for processing data from Kinesis

@Configuration
public class KinesisConsumerBinder{
   @Bean
   Consumer<String> kinesisConsumer(){
      return str ->{
        System.out.println("Data from Kinesis:"+str)
      }
   }

}

When i checked the log the kinesis stream name got changed automatically without any change in above yml configuration. Instead of taking "test-test.tst.v1" its taking "kinesisConsumer-in-o"

When I checked the log, I can see below log

main]o.s.c.s.b.k.p.KinesisStreamProvisioner : Using Kinesis stream for inbound: kinesisConsumer-in-o

My Expectation is : it should take Stream name as "test-test.tst.v1" instead of "kinesisConsumer-in-o"


Solution

  • You have a config like this:

      bindings:
        input-in-0:
          destination: test-test.tst.v1
    

    But your function is like this:

    Consumer<String> kinesisConsumer(){
    

    So, there is no connection between your property and real binding name which is indeed the kinesisConsumer-in-0.

    I believe you can fix your problem like this:

      bindings:
        kinesisConsumer-in-0:
          destination: test-test.tst.v1