kubele
08/11/2023, 4:20 PMSchedulers.fromExecutor(Executors.newFixedThreadPool(75))
My problem is that when I rewrote this:
@GetMapping("/get-stuff")
fun getStuff(
@RequestParam param: String
): Mono<ResponseObject> = Mono.fromCallable {
service.getStuff(param = param)
}.subscribeOn(blockingScheduler)
to use coroutines:
@GetMapping("/get-stuff")
suspend fun getStuff(
@RequestParam param: String
): ResponseObject = withContext(blockingScheduler.asCoroutineDispatcher()) {
service.getStuff(param = param)
}
the memory usage has increased almost 2-3 times.
Do you have any idea why the performance might so much worse? That's something I definitely did not expect.
Edit: I forgot to mention - the behaviour was the same when we tried to use <http://Dispatchers.IO|Dispatchers.IO>
instead of the schedulerJoão Gabriel Zó
08/22/2023, 4:35 PMchi
08/24/2023, 5:26 AM@Configuration
annotated class that defines some beans, is it necessary that I @Import
it in the @SpringBootApplication
annotated class? If I don’t do this the beans aren’t available in the application context, but if I do they are loaded. Examples I find online doesn’t do this it seems
For example, I defined a configuration class that sets up various settings for OpenAPI, if I don’t @Import
this class in the main application class my beans don’t get used, but if I do they get used, however examples I saw online doesn’t do this.igor.wojda
09/04/2023, 12:07 PMFrancis
09/05/2023, 4:40 PMsdeleuze
09/07/2023, 10:38 AMecho
09/08/2023, 5:32 AMHamza GATTAL
09/09/2023, 3:59 PMHoosain Madhi
09/13/2023, 3:00 PMHoosain Madhi
09/17/2023, 7:52 PMigor.wojda
09/18/2023, 8:40 AMmvn clean package
command fails with error. Coming from Android I have never seen such behaviour (at least when dependency is not used) 🤔. Any Spring Ninja 🥷 could take a look and help me with fixing this or at least share more light to help understand why this happens?
https://github.com/LemonAppDev/konsist/discussions/555Olufemi Adeojo
09/24/2023, 12:50 PM@Configuration
class SecurityConfig {
@Bean
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http
.csrf { obj: CsrfConfigurer<HttpSecurity> -> obj.disable() }
.oauth2ResourceServer { oauth2: OAuth2ResourceServerConfigurer<HttpSecurity?> ->
oauth2.jwt(
Customizer.withDefaults()
)
}
return http.build()
}
}
Olufemi Adeojo
09/24/2023, 12:51 PM. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.4)
2023-09-24T08:48:34.546-04:00 INFO 10957 --- [ restartedMain] com.freighthero.secu.SecuApplicationKt : Starting SecuApplicationKt using Java 17.0.8.1 with PID 10957 (/Users/oadeojo/Development/kotlin/spring/secu/build/classes/kotlin/main started by oadeojo in /Users/oadeojo/Development/kotlin/spring/secu)
2023-09-24T08:48:34.547-04:00 INFO 10957 --- [ restartedMain] com.freighthero.secu.SecuApplicationKt : No active profile set, falling back to 1 default profile: "default"
2023-09-24T08:48:34.574-04:00 INFO 10957 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-09-24T08:48:34.574-04:00 INFO 10957 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-09-24T08:48:35.147-04:00 WARN 10957 --- [ restartedMain] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityFilterChain' defined in class path resource [com/freighthero/secu/SecurityConfig.class]: Unsatisfied dependency expressed through method 'securityFilterChain' parameter 0: No qualifying bean of type 'org.springframework.security.config.annotation.web.builders.HttpSecurity' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2023-09-24T08:48:35.155-04:00 INFO 10957 --- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-09-24T08:48:35.164-04:00 ERROR 10957 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method securityFilterChain in com.freighthero.secu.SecurityConfig required a bean of type 'org.springframework.security.config.annotation.web.builders.HttpSecurity' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.config.annotation.web.builders.HttpSecurity' in your configuration.
Process finished with exit code 0
Olufemi Adeojo
09/25/2023, 11:16 AMGrzegorz Medias
09/25/2023, 7:38 PMErmac Wins
09/26/2023, 6:13 PMsdeleuze
09/27/2023, 7:55 PMKyle
09/30/2023, 5:32 PM{
"epochSeconds": 1696094517,
"value$kotlinx_datetime": "2023-09-30T17:21:57Z",
"nanosecondsOfSecond": 0
}
any ideas as to why it wouldn’t be using the correct serializer? I think it’s switching back to jackson for serializationwakingrufus
10/09/2023, 2:27 PMJarle Hansen
10/11/2023, 12:23 PMoverride fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
return Mono.deferContextual {
if (it.hasKey(MYID)) {
MDC.putCloseable(MYID, it.get(MYID))
}
chain.filter(exchange)
}
}
The @RestControntroller functions are all suspended, and we are running netty (so full webflux). In the async
code I have also added the MDCContext(), to make sure the MDC values are passed in. Is this a good solution? Are there any other pitfalls I need to be aware of? Or does anyone have a better implementation for this scenariowakingrufus
10/19/2023, 1:03 PMsdeleuze
10/19/2023, 4:14 PMDušan Salay
10/20/2023, 8:30 AMprivate val coroutineScope = CoroutineScope(Dispatchers.Unconfined)
private val logger: Logger = LoggerFactory.getLogger("BirthdayCongratulationScheduler::class.java")
/**
* Set up cron which starts every 10 seconds
*/
@Scheduled(cron = CRON_SCHEDULE)
@SchedulerLock(name = CRON_NAME)
fun congratulate() {
val handler = CoroutineExceptionHandler { _, exception ->
logger.error("CoroutineExceptionHandler got $exception")
}
runCatching {
logger.info("CRON $CRON_NAME has started.")
coroutineScope.launch(handler) {
throw RuntimeException("Not implemented")
}
}.onFailure { throwable ->
logger.error("CRON $CRON_NAME has failed. Check the error message: ${throwable.message}.")
}.onSuccess {
logger.info("CRON $CRON_NAME has finished.")
}
}
companion object {
private const val CRON_NAME = "myScheduler"
private const val CRON_SCHEDULE = "*/10 * * * * *"
}
and this is print log from console:
Started ApiApplicationKt in 8.411 seconds (process running for 8.76)
2023-10-20T10:22:10.103+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has started.
2023-10-20T10:22:10.106+02:00 ERROR 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CoroutineExceptionHandler got java.lang.RuntimeException: Not implemented
2023-10-20T10:22:10.106+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has finished.
2023-10-20T10:22:20.032+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has started.
2023-10-20T10:22:20.034+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has finished.
2023-10-20T10:22:30.033+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has started.
2023-10-20T10:22:30.033+02:00 INFO 82566 --- [ scheduling-1] .h.e.s.s.BirthdayCongratulationScheduler : CRON birthdayScheduler has finished.
repeating infinitely...
I am really confused, why CoroutineExceptionHandler
is catching the exception only one time. And after that the cron is still running without calling the logic in runCatching{}
as you can see in print in console? Can someone explain it to me? Or just provide link where I can read about this? Is this approach even correct? Or what is the best practise to call suspend functions in body of Scheduled method?
thanks,
DusanAxel
10/20/2023, 10:06 AMErmac Wins
10/23/2023, 7:15 AMAxel
10/25/2023, 7:53 AMwakingrufus
10/26/2023, 2:10 PMinline fun <reified T : Any> PropertyResolver.getProperty(key: String, default: T): T {
return getProperty(key, T::class.java, default)
}
upstream to spring? (can anyone on the spring team here give me some guidance on that?)Hamza GATTAL
10/26/2023, 3:55 PMfirebase-admin
in SpringBoot
to build GraalVM native imageAnudeep Ananth
10/27/2023, 1:59 AMgilarc
11/04/2023, 8:44 AMJava
with Spring
, or will Spring use Kotlin
more frequently in the future?