https://kotlinlang.org logo
Title
g

Gunslingor

08/17/2019, 11:46 PM
I'm confused about SpringApplication.run, I think I need to use a coorutine. ATM I have this SpringApplication.run statement in my main and 3 lines of other things I need to do every 5 minutes; how would I accomplish that?
r

Robert Jaros

08/17/2019, 11:54 PM
You can use spring scheduled tasks for that
g

Gunslingor

08/17/2019, 11:57 PM
hmm... interesting, will read up on that. SpringApplication.run, runs the REST API... but then these other 3 lines file up the database that the REST API uses. What's better a spinger scheduled task or kotlin corutine?
r

Robert Jaros

08/18/2019, 12:04 AM
You can probably schedule tasks with coroutines, but i'm not sure how it will work for long-running applications or whether it will work correctly with spring components.
g

Gunslingor

08/18/2019, 12:05 AM
thanks, looks like spring scheduled tasks are going to work out ok... thanks man, saved me time.
r

Robert Jaros

08/18/2019, 12:06 AM
I would probably use dedicated solution - it will give you much more scheduling options.
s

sdeleuze

08/19/2019, 9:07 AM
You can use
runApplication
top level function instead, it is designed to provide a more idiomatic Kotlin syntax, see generated code on https://start.spring.io.