Hello I am searching a documentation about the new...
# spring
m
Hello I am searching a documentation about the new https://docs.spring.io/spring-cloud-stream/docs/3.1.1/reference/html/spring-cloud-stream.html#spring-cloud-stream-overview-introducing with Kotlin ….. about
Function,Supplier,Consumer
do I need maybe also the
spring-cloud-function-kotlin
for this ? I try to migrate my sample application to the new API
Copy code
@SpringBootApplication
class ProducerApplication
fun main(args: Array<String>) {
    runApplication<ProducerApplication>(*args)
}
@RestController
@RequestMapping(value = ["/producer"])
class ProducerController(private val producerMessagingService: ProducerMessagingService) {

    private val log = LoggerFactory.getLogger(javaClass)

    @PostMapping(value = ["{message}"])
    fun message(@PathVariable message: String) {
        <http://log.info|log.info>("------------> Receive message {} <-------------", message)
        producerMessagingService.sendMessage(message)
    }
}
@Service
class ProducerMessagingService(private val producerSource: ProducerSource) {
    fun sendMessage(message: String) = producerSource.producerChannel().send(MessageBuilder.withPayload(message).build())
}
interface ProducerSource {
    @Output(value = "producerOutput")
    fun producerChannel(): MessageChannel
}
@Configuration
@EnableBinding(value = [ProducerSource::class])
class MessagingConfig
s
Hey, I will ask and send you a feedback
Please ask your question on Stack Overflow with
spring-cloud-function
tag and our team will answer you.
Feel free to share the link here in order to allow me to follow it to the right person.
👍 1
m
Hello great thank… I found a solution in a old gitter chat https://github.com/marzelwidmer/spring-cloud-streams-kotlin/tree/producer_consumer it works if it the best practice I am not sure 🙂 the message stuff a new for me…
Copy code
@Bean
    fun kotlinConsumer(): Consumer<String> = Consumer {
        val message = it.toUpperCase()
        println(message)
        streamBridge.send("producerOutput", MessageBuilder.withPayload(message).build())
    }
I was confused about
Consumer
etc. my brain was on message side.. an not on Java Function Side 🙂