Class DedupAutoConfiguration

java.lang.Object
com.aim2be.platform.dedup.DedupAutoConfiguration

@AutoConfiguration @ConditionalOnProperty(prefix="im2be.dedup", name="enabled", havingValue="true") @EnableConfigurationProperties(DedupProperties.class) @EnableJpaRepositories(basePackageClasses=ProcessedKafkaEventRepository.class) @EntityScan(basePackageClasses=ProcessedKafkaEvent.class) public class DedupAutoConfiguration extends Object
Spring Boot auto-configuration for the processed-kafka-events dedup module.

Activated when im2be.dedup.enabled=true is set in a consuming application's application.properties. Wires:

  • DedupProperties — type-safe config binding
  • ProcessedKafkaEventRepository — Spring Data JPA repository
  • DedupMetricsBinder — Micrometer counters + gauges
  • DedupGuard — the public dedup API bean. Its tracer is resolved per call via a Supplier that prefers a Spring-bean OpenTelemetry, falls back to GlobalOpenTelemetry.get() (set by the OTel Java Agent), and finally to OpenTelemetry.noop() when no OTel is present.
  • Clock (fallback) — UTC system clock when none is supplied

EntityScan + EnableJpaRepositories are scoped to the dedup package so the consuming service does NOT need to extend its own @EntityScan list — the autoconfiguration is self-contained.

Registered via META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports.

  • Constructor Details

    • DedupAutoConfiguration

      public DedupAutoConfiguration()
  • Method Details

    • dedupClock

      @Bean @ConditionalOnMissingBean public Clock dedupClock()
      UTC system clock — used by DedupMetricsBinder to determine the "current" week for the active-partitions gauge. Marked ConditionalOnMissingBean so test contexts (or services with their own fixed clock) can override.
      Returns:
      UTC system clock
    • dedupMetricsBinder

      @Bean @ConditionalOnMissingBean public DedupMetricsBinder dedupMetricsBinder(io.micrometer.core.instrument.MeterRegistry registry, ProcessedKafkaEventRepository repository, Clock clock)
      Metrics binder bean. MeterRegistry is autowired from the host application's Micrometer wiring (Spring Boot Actuator brings a default registry; if none is present the autoconfig fails fast — the dedup module requires observability).
      Parameters:
      registry - the application's meter registry
      repository - the dedup repository for gauge polling
      clock - the clock for current-week resolution
      Returns:
      a DedupMetricsBinder
    • dedupGuard

      @Bean @ConditionalOnMissingBean public DedupGuard dedupGuard(ProcessedKafkaEventRepository repository, DedupMetricsBinder metrics, org.springframework.beans.factory.ObjectProvider<io.opentelemetry.api.OpenTelemetry> otelProvider, Clock clock, DedupProperties props)
      DedupGuard singleton — the module's public API.

      R3 MINOR fix: the previous version defined a Tracer bean here that snapshotted the OpenTelemetry bean at bean-creation time — even with ObjectProvider.getIfAvailable(), the resolution still fired during this factory method's execution. Replaced with a deferred supplier passed into DedupGuard; the guard re-resolves the tracer on every tryClaim invocation, so an OTel SDK registered AFTER this autoconfig completes is honoured.

      Parameters:
      repository - the JPA repository
      metrics - the Micrometer binder
      otelProvider - deferred provider — re-resolved per call inside the guard so post-startup OTel SDK registration takes effect without restart
      clock - the clock used for first_seen_at stamping
      props - properties (carries defaultScopeId)
      Returns:
      a fully-wired guard