Skip to content

Code example in the documentation for Dynamically Creating Containers - Prototype Beans (Kotlin) is wrong #3513

@mohamedmelfiky

Description

@mohamedmelfiky

Spring Kafka 3.2.4

In the documentation for Dynamically Creating Containers - Prototype Beans (Kotlin) the example throw exception.
It should be as follow instead

  class MyPojo(val id: String, val topic: String) {

      @KafkaListener(id = "#{__listener.id}", topics = ["#{__listener.topic}"])
      fun listen(`in`: String?) {
          println(`in`)
      }
  
  }
  
  @Bean
  @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
  fun pojo(id: String, topic: String): MyPojo {
      return MyPojo(id, topic)
  }
  
  applicationContext.getBean(MyPojo::class.java, "one", "topic2")
  applicationContext.getBean(MyPojo::class.java, "two", "topic3")

Link to the above mentioned documentation paragraph:

https://docs.spring.io/spring-kafka/reference/kafka/dynamic-containers.html#prototype-beans

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions