Class AsyncConfig

java.lang.Object
springboot.bg.harisauto.common.config.async.AsyncConfig

@Configuration @EnableAsync public class AsyncConfig extends Object
AsyncConfig.java - Enables @Async execution and defines the executor it uses.

Without EnableAsync every @Async method runs inline on the calling thread. That matters most for the registration welcome email: it is a synchronous @EventListener that declares a checked MessagingException, so an SMTP failure would propagate into the registration transaction and roll the new user back.

Author:
Kristian Popov
  • Constructor Details

    • AsyncConfig

      public AsyncConfig()
  • Method Details

    • taskExecutor

      @Bean(name="taskExecutor") public Executor taskExecutor()
      Bounded executor for @Async work, so a slow mail server cannot exhaust threads.