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
6 tasks
ramafasa
suggested changes
Mar 31, 2026
|
|
||
| @ConfigurationProperties(prefix = "okapi.purger") | ||
| @Validated | ||
| data class OutboxPurgerProperties( |
Collaborator
Author
There was a problem hiding this comment.
here it would be a dead property - nothing really reads it. 'enabled' is handled in @ConditionalOnProperty on outboxPurgerScheduler bean
endrju19
added a commit
that referenced
this pull request
Apr 1, 2026
…ifecycle (KOJAK-62) (#14) ## Summary Apply the same production-ready pattern from KOJAK-56 (OutboxPurger v2) to OutboxScheduler and OutboxProcessorScheduler: - **Fix silent death bug**: `OutboxScheduler.tick()` had no try/catch — `ScheduledExecutorService` silently stops on uncaught exception. Added `catch(Exception)` with SLF4J error logging. - **Add lifecycle guards**: `AtomicBoolean` running flag prevents double-start, `check(!scheduler.isShutdown)` prevents restart-after-stop with a clear error message, `isRunning()` method. - **Extract config value object**: `OutboxSchedulerConfig` data class with `require()` validation in init block (make illegal states unrepresentable). - **Migrate to SmartLifecycle**: Replace `SmartInitializingSingleton + DisposableBean` with `SmartLifecycle`. Phase ordering: processor (`MAX_VALUE - 2048`) starts before purger (`MAX_VALUE - 1024`) and stops after it. `stop(callback)` with `try-finally`. - **Spring properties binding**: `OutboxProcessorProperties` with `@ConfigurationProperties(prefix = "okapi.processor")`, `@Validated`, `@field:Min(1)`. `@ConditionalOnProperty` for `enabled` toggle. - **Database index**: `(status, created_at)` composite index for `claimPending()` query performance (Postgres + MySQL). - **Configuration metadata**: Processor properties added to `spring-configuration-metadata.json`. ### Configuration ```yaml okapi: processor: enabled: true # default interval-ms: 1000 # default batch-size: 10 # default ``` ### Commits (8) | Commit | Scope | |--------|-------| | `feat(core): add OutboxSchedulerConfig value object with validation` | okapi-core | | `feat(core): rewrite OutboxScheduler with error handling, guards, logging` | okapi-core | | `feat(spring): add OutboxProcessorProperties` | okapi-spring-boot | | `feat(spring): migrate OutboxProcessorScheduler to SmartLifecycle` | okapi-spring-boot | | `feat(spring): bind OutboxProcessorProperties in OutboxAutoConfiguration` | okapi-spring-boot | | `test(spring): add OutboxProcessorAutoConfigurationTest` | okapi-spring-boot | | `feat(db): add index (status, created_at) for processor claimPending query` | okapi-postgres, okapi-mysql | | `feat(spring): add processor properties to spring-configuration-metadata.json` | okapi-spring-boot | ## Test plan - [x] `OutboxSchedulerConfigTest` — 6 tests (defaults, custom values, validation) - [x] `OutboxSchedulerTest` — 7 tests (batchSize forwarding, error recovery, double-start, isRunning transitions, restart-after-stop, transactionRunner wrapping, no transactionRunner) - [x] `OutboxProcessorAutoConfigurationTest` — 7 tests (bean creation, disabled toggle, properties binding, defaults, SmartLifecycle isRunning, validation, stop callback) - [x] All existing tests pass (purger, publisher, E2E) - [x] `./gradlew clean check` — BUILD SUCCESSFUL - [x] `./gradlew ktlintCheck` — clean ## Related - Depends on: #11 (KOJAK-56, OutboxPurger v2) — base branch is `feat102` - Related: KOJAK-61 (OutboxPurgerConfig extraction — separate task, uses `OutboxSchedulerConfig` as reference pattern) - JIRA: [KOJAK-62](https://softwaremill.atlassian.net/browse/KOJAK-62)
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
Makes OutboxPurger a production-ready, configurable component — establishing a pattern to replicate for OutboxScheduler/ProcessorScheduler.
FOR UPDATE SKIP LOCKED(Postgres subquery, MySQL derived table wrapper) — prevents full table scans and lock contention on large tablestry/catchintick()preventsScheduledExecutorServicefrom silently dying on exceptions@ConfigurationPropertiesbinding fromapplication.yml(okapi.purger.retention-days,interval-minutes,batch-size,enabled)SmartInitializingSingleton + DisposableBeanfor phase-ordered startup/shutdown(status, last_attempt)composite index for efficient purge queriesBreaking change
OutboxStore.removeDeliveredBefore(Instant)→removeDeliveredBefore(Instant, Int): Int— accepts batch limit, returns count deleted. Pre-1.0, no external consumers.Key design decisions
FOR UPDATE SKIP LOCKEDin purgespring-configuration-metadata.jsonimplementationfor SLF4JMAX_BATCHES_PER_TICK = 10check(!scheduler.isShutdown)RejectedExecutionExceptionon restart after stopJIRA
Test plan
OutboxPurgerTest(batch loop, error recovery, double-start, restart guard, validation)OutboxPurgerAutoConfigurationTest(property binding, conditional beans, lifecycle, stop callback)removeDeliveredBeforewith limit test (Testcontainers)