Class SchemaRegistryAutoConfiguration

java.lang.Object
com.aim2be.platform.schema.SchemaRegistryAutoConfiguration

@AutoConfiguration @AutoConfigureAfter(name="io.opentelemetry.instrumentation.spring.autoconfigure.OpenTelemetryAutoConfiguration") @EnableConfigurationProperties(SchemaRegistryProperties.class) @ConditionalOnProperty(prefix="im2be.schema-registry", name="enabled", havingValue="true") public class SchemaRegistryAutoConfiguration extends Object
Spring Boot auto-configuration for the apicurio-client module.

Activated when im2be.schema-registry.enabled=true. The mode property selects exactly ONE SchemaRegistryClient bean:

The RegistryClient (Apicurio v2 REST client) is constructed once and shared across whichever client variant is active. Consumers can override the RegistryClient bean (e.g. to supply an authenticated variant) — the @ConditionalOnMissingBean guard yields to user overrides.

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

  • Constructor Details

    • SchemaRegistryAutoConfiguration

      public SchemaRegistryAutoConfiguration()
  • Method Details

    • apicurioRegistryClient

      @Bean @ConditionalOnMissingBean public io.apicurio.registry.rest.client.RegistryClient apicurioRegistryClient(SchemaRegistryProperties props)
      Builds the Apicurio v2 REST client targeting SchemaRegistryProperties.getUrl().

      @ConditionalOnMissingBean lets consumers supply their own authenticated RegistryClient (e.g. with OIDC bearer tokens).

      Parameters:
      props - bound properties; never null
      Returns:
      the Apicurio REST client
    • schemaRegistryOpenTelemetry

      @Bean @ConditionalOnMissingBean public io.opentelemetry.api.OpenTelemetry schemaRegistryOpenTelemetry()
      Falls back to a no-op OpenTelemetry instance ONLY when no real OpenTelemetry bean is present; lets the client emit spans without forcing every consumer to wire OTel up first.

      Ordering matters (#343). The class-level @AutoConfigureAfter(name = "…OpenTelemetryAutoConfiguration") ensures the OpenTelemetry Spring Boot starter's real SDK bean is registered before this @ConditionalOnMissingBean is evaluated, so the real bean wins when the starter is active. Without that ordering this no-op could win the race and make the starter's real bean (itself @ConditionalOnMissingBean) back off — silently disabling all OTel export. When the starter is absent or excluded, @ConditionalOnMissingBean registers this no-op so the SchemaRegistryClient beans' required OpenTelemetry constructor param is still satisfied.

      Returns:
      a no-op OpenTelemetry
    • apicurioSchemaRegistryClient

      @Bean @ConditionalOnProperty(prefix="im2be.schema-registry", name="mode", havingValue="apicurio", matchIfMissing=true) public SchemaRegistryClient apicurioSchemaRegistryClient(io.apicurio.registry.rest.client.RegistryClient client, SchemaRegistryProperties props, io.opentelemetry.api.OpenTelemetry openTelemetry)
      Primary path: Apicurio native 8-byte globalId prefix. Default mode.
      Parameters:
      client - the Apicurio REST client
      props - configuration properties
      openTelemetry - the OTel instance
      Returns:
      the Apicurio implementation of SchemaRegistryClient
    • confluentWireCompatSchemaRegistryClient

      @Bean @ConditionalOnProperty(prefix="im2be.schema-registry", name="mode", havingValue="confluent") public SchemaRegistryClient confluentWireCompatSchemaRegistryClient(io.apicurio.registry.rest.client.RegistryClient client, SchemaRegistryProperties props, io.opentelemetry.api.OpenTelemetry openTelemetry)
      Confluent wire-format hedge: Apicurio storage backend + 4-byte schemaId prefix at the wire.
      Parameters:
      client - the Apicurio REST client
      props - configuration properties
      openTelemetry - the OTel instance
      Returns:
      the Confluent-wire-compat implementation
    • dualSchemaRegistryClient

      @Bean @ConditionalOnProperty(prefix="im2be.schema-registry", name="mode", havingValue="dual") public SchemaRegistryClient dualSchemaRegistryClient(io.apicurio.registry.rest.client.RegistryClient client, SchemaRegistryProperties props, io.opentelemetry.api.OpenTelemetry openTelemetry)
      Dual coordinator: wire-format coexistence layer (DualSchemaRegistryClient). Both delegates wrap the SAME RegistryClient; the divergence is producer-side wire format (Apicurio 8-byte vs Confluent 4-byte). NOT an HA hedge — outages from the primary propagate (the fallback delegate shares the underlying registry endpoint). See DualSchemaRegistryClient class Javadoc for the design rationale.
      Parameters:
      client - the Apicurio REST client
      props - configuration properties
      openTelemetry - the OTel instance
      Returns:
      the dual coordinator