feat: OutboxProcessorScheduler — configurability, reliability, SmartLifecycle (KOJAK-62)#14
Open
feat: OutboxProcessorScheduler — configurability, reliability, SmartLifecycle (KOJAK-62)#14
Conversation
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.
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)