life is too short for a diary




Daily Logs for Sep 22, 2025

Tags: java letters

Author
Written by: Tushar Sharma
Featured image for Daily Logs for Sep 22, 2025

Dear Vishi, dear logs for today.

Spring Boot Startup Lifecycle

When to Use What?

Hook / Event Vibe 💬 Best For
@PostConstruct "I’m a bean — I’m setting up MYSELF." Bean-specific init: open connection, load config, validate deps
SmartLifecycle "I’m a background worker — start me when the app is ready, but before traffic." Long-running services: pollers, listeners, async processors (with graceful stop)
CommandLineRunner "I’m a script — run me once, after everything’s wired, before the server opens." One-time setup: preload data, print args, warm cache, send startup log
ApplicationReadyEvent "Server is live — now do your final thing." Final go-live tasks: call health endpoints, notify Slack, start polling external APIs

Flux.Iterable in Java Reactive

Both of these are equivalent

Flux<String> foo = Flux.just("cat", "dog");
Flux<String> bar = Flux.fromIterable(List.of("cat", "dog"));

foo.subscribe(System.out::println);
bar.subscribe(System.out::println);

For small fixed values, Flux.just is fine. When working with an existing collection or a large list, prefer Flux.fromIterable, since Flux.just is not designed to take a collection directly and can lead to performance issues if used that way.

Tweet from Alexander Duncan

Alexander Duncan is a Republican Candidate for U.S. Senate. I saw this tweet about Hinduism:


comments powered by Disqus