Spring Boot integration
Latest stable Based on Leader release 0.4.0
Library module
Problem
Section titled “Problem”Provides Spring Boot auto-configuration, backend factories, compile-time-woven AOP for @LeaderElection/@LeaderGroupElection, SpEL lock names, failure policy, and lock scope utilities.
When to use it
Section titled “When to use it”Use it for Spring-managed jobs that benefit from declarative election. Use direct elector calls when ownership should remain explicit in application code.
Coordinates
Section titled “Coordinates”Artifact: io.github.bluetape4k.leader:bluetape4k-leader-spring-boot
dependencies { implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>")) implementation("io.github.bluetape4k.leader:bluetape4k-leader-spring-boot")}Core concepts
Section titled “Core concepts”The aspect resolves a factory, builds options, acquires, and invokes the method only when elected. Private methods are not intercepted. This project uses AspectJ compile-time weaving, so @EnableAspectJAutoProxy is not the activation switch.
Quick start
Section titled “Quick start”@Serviceclass Jobs { @LeaderElection(name = "daily-settlement", leaseTime = "30m") fun settle(): SettlementReport? = settlementService.settle()}API by task
Section titled “API by task”Use @LeaderElection for one owner and @LeaderGroupElection for bounded parallelism. Select a factory with @LeaderElectionBackend; LockAssert/LockExtender work only inside an active scope.
Recommended patterns
Section titled “Recommended patterns”Keep annotated methods externally reachable by the woven aspect, use stable or validated SpEL names, disable method invocation in SpEL unless trusted, and keep FAIL_OPEN_RUN for idempotent work only.
Integrations
Section titled “Integrations”Auto-configuration supports available backend clients and Micrometer recording. batch-scheduler and webhook-poller show annotation-driven jobs.
Configuration
Section titled “Configuration”Configure defaults under bluetape4k.leader, backend-specific properties, AOP order, failure mode, SpEL policy, single/group leases, and factory bean selection.
Failure modes
Section titled “Failure modes”RETHROW surfaces backend failure, SKIP suppresses execution, and FAIL_OPEN_RUN executes without ownership. Invalid annotations or ambiguous factories should fail startup. Long streams need explicit renewal.
Operations
Section titled “Operations”Monitor elected/skipped/failure outcomes, selected factory, resolved lock name, duration, and extension. Document fail-open decisions in the runbook.
Testing
Section titled “Testing”Use application-context tests for auto-configuration and CTW interception; cover private/non-intercepted methods, SpEL, meta-annotations, failure modes, suspend/reactive results, and cancellation.
Workshops and learning path
Section titled “Workshops and learning path”Start with batch-scheduler, then webhook-poller and prometheus-dashboard. Read the chosen backend manual for its client and lease operations.
Limitations
Section titled “Limitations”AOP cannot make arbitrary side effects exactly once. Self/private invocation and long-lived streams require careful boundary testing; FAIL_OPEN_RUN permits duplicates by design.
Release diagrams
Section titled “Release diagrams”These diagrams are loaded directly from README assets published with the 0.4.0 release and pinned to its immutable commit. They describe this manual’s released structure and runtime flows, not later Snapshot changes. Select a preview to open the SVG at the same release commit.
leader spring boot Architecture diagram
Section titled “leader spring boot Architecture diagram”Release README: leader-spring-boot/README.md
Sequence: AOP-triggered runIfLeader diagram
Section titled “Sequence: AOP-triggered runIfLeader diagram”Release README: leader-spring-boot/README.md
Sequence: reentrant @LeaderElection diagram
Section titled “Sequence: reentrant @LeaderElection diagram”Release README: leader-spring-boot/README.md


