feat: OutboxProcessorScheduler — configurability, reliability, SmartLifecycle (KOJAK-62)#14
Merged
feat: OutboxProcessorScheduler — configurability, reliability, SmartLifecycle (KOJAK-62)#14
Conversation
…and return count Breaking change: removeDeliveredBefore(Instant) -> removeDeliveredBefore(Instant, Int): Int Store implementations temporarily ignore limit parameter.
… logging, validation
…rom OkapiPurgerProperties
…nding and conditional beans Also fix nested PostgresStoreConfiguration to use proxyBeanMethods=false (Kotlin classes are final; CGLIB proxying requires non-final classes) and add assertj-core to version catalog (required by spring-boot-test's ApplicationContextRunner).
The enabled flag is handled by @ConditionalOnProperty on the bean factory. Having it also in the properties class was redundant — no code read it.
…, KDoc, test coverage - OutboxPurger.start(): check(!scheduler.isShutdown) prevents restart after stop - OutboxPurgerScheduler.stop(callback): try-finally guarantees callback invocation - OutboxStore.removeDeliveredBefore: verbose KDoc with @param/@return contract - OutboxAutoConfiguration.outboxStore(): restore concrete PostgresOutboxStore return type - OutboxPurgerTest: assert batchSize is forwarded as limit, test start-after-stop
…ies, improve test assertions - Rename OkapiPurgerProperties -> OutboxPurgerProperties (consistent with Outbox* naming convention) - Add latch.await() shouldBe true assertions for better timeout diagnostics - Add stop callback invocation test for SmartLifecycle contract
Add try/catch in tick() to prevent silent scheduler death on exception. Add AtomicBoolean running guard and isShutdown restart check. Accept OutboxSchedulerConfig instead of raw parameters. Add SLF4J logging: INFO start/stop, DEBUG per tick, ERROR on failure. Add isRunning() method.
Replace SmartInitializingSingleton + DisposableBean with SmartLifecycle. Add stop(callback) with try-finally to prevent Spring shutdown hang. Add phase ordering: processor (MAX_VALUE-2048) starts before purger (MAX_VALUE-1024) and stops after it. Accept OutboxSchedulerConfig instead of raw parameters.
Add @EnableConfigurationProperties for OutboxProcessorProperties. Add @ConditionalOnProperty for okapi.processor.enabled toggle. Map properties to OutboxSchedulerConfig in bean factory.
Test: bean creation, disabled toggle, properties binding, defaults, SmartLifecycle isRunning, validation, stop callback safety.
…uery Without this index, claimPending() does a full table scan on SELECT ... WHERE status='PENDING' ORDER BY created_at.
ramafasa
approved these changes
Apr 1, 2026
- Changelogs: use upstream's *_claim_index names (same index, added independently) - Remove duplicate *_processor_index migrations (identical to upstream's *_claim_index) - PostgresOutboxStore: accept upstream's Exposed DSL refactor for claimPending - AutoConfiguration: keep both purger + processor @EnableConfigurationProperties - Metadata JSON: keep superset with processor properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Apply the same production-ready pattern from KOJAK-56 (OutboxPurger v2) to OutboxScheduler and OutboxProcessorScheduler:
OutboxScheduler.tick()had no try/catch —ScheduledExecutorServicesilently stops on uncaught exception. Addedcatch(Exception)with SLF4J error logging.AtomicBooleanrunning flag prevents double-start,check(!scheduler.isShutdown)prevents restart-after-stop with a clear error message,isRunning()method.OutboxSchedulerConfigdata class withrequire()validation in init block (make illegal states unrepresentable).SmartInitializingSingleton + DisposableBeanwithSmartLifecycle. Phase ordering: processor (MAX_VALUE - 2048) starts before purger (MAX_VALUE - 1024) and stops after it.stop(callback)withtry-finally.OutboxProcessorPropertieswith@ConfigurationProperties(prefix = "okapi.processor"),@Validated,@field:Min(1).@ConditionalOnPropertyforenabledtoggle.(status, created_at)composite index forclaimPending()query performance (Postgres + MySQL).spring-configuration-metadata.json.Configuration
Commits (8)
feat(core): add OutboxSchedulerConfig value object with validationfeat(core): rewrite OutboxScheduler with error handling, guards, loggingfeat(spring): add OutboxProcessorPropertiesfeat(spring): migrate OutboxProcessorScheduler to SmartLifecyclefeat(spring): bind OutboxProcessorProperties in OutboxAutoConfigurationtest(spring): add OutboxProcessorAutoConfigurationTestfeat(db): add index (status, created_at) for processor claimPending queryfeat(spring): add processor properties to spring-configuration-metadata.jsonTest plan
OutboxSchedulerConfigTest— 6 tests (defaults, custom values, validation)OutboxSchedulerTest— 7 tests (batchSize forwarding, error recovery, double-start, isRunning transitions, restart-after-stop, transactionRunner wrapping, no transactionRunner)OutboxProcessorAutoConfigurationTest— 7 tests (bean creation, disabled toggle, properties binding, defaults, SmartLifecycle isRunning, validation, stop callback)./gradlew clean check— BUILD SUCCESSFUL./gradlew ktlintCheck— cleanRelated
feat102OutboxSchedulerConfigas reference pattern)