Class OutboxLifecycle

java.lang.Object
io.outbox.spring.boot.OutboxLifecycle
All Implemented Interfaces:
org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class OutboxLifecycle extends Object implements org.springframework.context.SmartLifecycle
Manages the outbox lifecycle: starts the poller after all listeners are registered, and stops the poller/dispatcher during application shutdown.

Spring guarantees SmartInitializingSingleton (used by OutboxListenerRegistrar) runs before Lifecycle.start(). This eliminates the startup race where the poller could poll events before listeners are registered.

stop() delegates to Outbox.close(), which drains in-flight events and shuts down the poller and dispatcher threads.

  • Field Summary

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    void
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.SmartLifecycle

    getPhase, isAutoStartup, stop
  • Constructor Details

    • OutboxLifecycle

      public OutboxLifecycle(Outbox outbox)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle