Skip to main content

Events, Scheduling, Async, and Observability

Cert Focus

You should understand how Spring handles in-process events, scheduled work, async execution, and production diagnostics.

Must Know

  • ApplicationEventPublisher publishes events inside the Spring application context.
  • @EventListener handles events.
  • Spring events are synchronous by default.
  • @TransactionalEventListener can run listeners around transaction phases such as AFTER_COMMIT.
  • @Scheduled runs methods based on time.
  • @EnableScheduling enables scheduled methods.
  • fixedRate means start-to-start.
  • fixedDelay means finish-to-next-start.
  • @Async runs methods in another thread.
  • @EnableAsync enables async method execution.
  • @Async is proxy-based, so self-invocation can bypass it.
  • Actuator exposes production diagnostics such as health, info, metrics, mappings, beans, conditions, and scheduled tasks.
  • Expose and secure Actuator endpoints carefully.

Exam Traps

Events are not a message broker. They are in-process and not durable.

@Scheduled is not a distributed job platform. Every app instance may run the same job unless you design around it.

@Async does not automatically share transaction, request, or security context.

Self-Check

  • Can I explain synchronous Spring events?
  • Can I explain AFTER_COMMIT?
  • Can I explain fixedRate vs fixedDelay?
  • Can I explain why every app instance may run the same scheduled job?
  • Can I name Actuator endpoints that should be secured?
Model Answers

Spring events are synchronous by default, so the publisher waits while listeners run unless async execution is configured.

AFTER_COMMIT means a transactional event listener runs only after the surrounding transaction commits successfully.

fixedRate is start-to-start timing. fixedDelay is finish-to-next-start timing.

Every app instance may run the same scheduled job because @Scheduled is local to each running application instance. Multi-instance deployments need locking, idempotency, or an external scheduler.

Actuator endpoints such as env, beans, configprops, mappings, conditions, loggers, and sometimes metrics should be carefully secured or not exposed publicly.

Memory Sentence

Events say something happened; scheduling is about time; async is about threads; Actuator makes production visible.