Skip to content

Commit

Permalink
GH-3513: Cleaning up Kotlin example in ref docs (#3541)
Browse files Browse the repository at this point in the history
Fixes: #3513

#3513
  • Loading branch information
sobychacko authored Oct 8, 2024
1 parent 3b64536 commit d040baa
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 the original author or authors.
* Copyright 2022-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,7 @@ import org.springframework.kafka.listener.MessageListener

/**
* @author Gary Russell
* @author Soby Chacko
* @since 2.8.9
*/
@SpringBootApplication
Expand All @@ -47,8 +48,8 @@ class Application {
return ApplicationRunner { _: ApplicationArguments? ->
// tag::getBeans[]

applicationContext.getBean(MyPojo::class.java, "one", arrayOf("topic2"))
applicationContext.getBean(MyPojo::class.java, "two", arrayOf("topic3"))
applicationContext.getBean(MyPojo::class.java, "one", "topic2")
applicationContext.getBean(MyPojo::class.java, "two", "topic3")
// end::getBeans[]
}
}
Expand Down Expand Up @@ -88,7 +89,7 @@ private fun createContainer(

@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
fun pojo(id: String?, topic: String?): MyPojo {
fun pojo(id: String, topic: String): MyPojo {
return MyPojo(id, topic)
}
//end::pojoBean[]
Expand All @@ -114,9 +115,9 @@ class MyListener : MessageListener<String?, String?> {

// tag::pojo[]

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

@KafkaListener(id = "#{__listener.id}", topics = ["#{__listener.topics}"])
@KafkaListener(id = "#{__listener.id}", topics = ["#{__listener.topic}"])
fun listen(`in`: String?) {
println(`in`)
}
Expand Down

0 comments on commit d040baa

Please sign in to comment.