Class DualSchemaRegistryClient

java.lang.Object
com.aim2be.platform.schema.DualSchemaRegistryClient
All Implemented Interfaces:
SchemaRegistryClient

public class DualSchemaRegistryClient extends Object implements SchemaRegistryClient
Wire-format hedge coordinator (ADR-0011 §B optional hedge).

Important — design clarification (R2 MAJOR fix): the "primary" and "fallback" delegates wrap the SAME underlying Apicurio registry. The dual client is NOT an HA hedge against registry outages; it's a wire-format coexistence layer. Both producers + consumers in a deployment may choose Apicurio 8-byte OR Confluent 4-byte wire prefixes, and the dual client makes both interpretations available against one Apicurio backend.

Behaviour:

  • register(String, byte[], SchemaType) — calls primary only. Any error from the primary (5xx / IOException / 4xx) propagates to the caller; the fallback is NEVER invoked at this method because it wraps the same underlying registry and retrying cannot recover from an outage there.
  • fetchByGlobalId(long) — primary only. Apicurio globalIds (long) and Confluent schemaIds (int) are NOT interchangeable; a caller that has only a wire-prefix-derived id must pre-decide which method to invoke based on the wire format. Falling back here would silently mis-map ids.
  • fetchLatestBySubject(String) — primary only; outages propagate (same rationale as register).
  • kind()SchemaRegistryClient.Kind.DUAL.
  • wireFormat() — returns the primary's wireFormat (Apicurio 8-byte by default).

The fallback delegate is retained on this class so the wire- format-hedging consumers may explicitly access it via getFallback(); routine register/fetch operations only ever consult the primary.

Activated when im2be.schema-registry.mode=dual.