Class ConfluentWireCompatSchemaRegistryClient
- All Implemented Interfaces:
SchemaRegistryClient
Talks to an Apicurio registry under the hood — same v2 REST API, same
artifact storage — but advertises WireFormat.CONFLUENT_4_BYTE as
its on-wire prefix. Producers built on top of this client emit records
using Confluent's 0x00 magic + 4-byte schemaId layout instead of
Apicurio's 8-byte globalId prefix.
This is the "Confluent if missed" hedge from
.planning/26-stage-b-outbox-parity.md §0 row L-19: if ADR-0011 §B
is overridden later and aim2be needs to stay wire-compatible with existing
Confluent consumers, switching every producer is a 1-bean config change
(im2be.schema-registry.mode=confluent) rather than a code rewrite.
Behaviour delta vs ApicurioSchemaRegistryClient:
kind()returnsSchemaRegistryClient.Kind.CONFLUENT_WIRE_COMPATwireFormat()returnsWireFormat.CONFLUENT_4_BYTE- register / fetch operations delegate verbatim to the Apicurio impl — the storage backend is the same, only the producer-side prefix chosen at emit time differs
Note: Apicurio's globalId is a long and Confluent's schemaId is
an int. The platform's choice (per ADR-0011 §B) is to widen the
Confluent id to long at the SchemaRegistryClient boundary;
downstream producer encoders narrow back to int via
WireFormatCodec.prependConfluentPrefix(int, byte[]) after a
range check. Operators must keep the registry's id allocator within the
31-bit positive int range during the period this mode is active.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.aim2be.platform.schema.SchemaRegistryClient
SchemaRegistryClient.Kind, SchemaRegistryClient.Schema, SchemaRegistryClient.SchemaType -
Constructor Summary
ConstructorsConstructorDescriptionConfluentWireCompatSchemaRegistryClient(io.apicurio.registry.rest.client.RegistryClient delegate, String groupId, String compatibility, io.opentelemetry.api.OpenTelemetry openTelemetry) -
Method Summary
Modifier and TypeMethodDescriptionfetchByGlobalId(long globalId) Fetches a schema by registry global ID.fetchLatestBySubject(String subject) Fetches the latest schema body registered undersubject.kind()Returns the implementation kind.longregister(String subject, byte[] schemaBytes, SchemaRegistryClient.SchemaType type) RegistersschemaBytesundersubject, returning the registry-assigned global ID.Returns the wire format this client emits / parses.
-
Constructor Details
-
ConfluentWireCompatSchemaRegistryClient
public ConfluentWireCompatSchemaRegistryClient(io.apicurio.registry.rest.client.RegistryClient delegate, String groupId, String compatibility, io.opentelemetry.api.OpenTelemetry openTelemetry) - Parameters:
delegate- the Apicurio v2 REST client; not nullgroupId- the artifact group ID; not nullcompatibility- compatibility rule (BACKWARD/FORWARD/FULL/NONE); forwarded to the inner Apicurio delegate. May be null/blank for no enforcement.openTelemetry- the OpenTelemetry instance; not null
-
-
Method Details
-
register
Description copied from interface:SchemaRegistryClientRegistersschemaBytesundersubject, returning the registry-assigned global ID.Idempotent: a re-registration of identical bytes returns the same global ID (Apicurio's
IfExists=RETURN_OR_UPDATEsemantics).- Specified by:
registerin interfaceSchemaRegistryClient- Parameters:
subject- the subject name (typically<topic>-valueor<topic>-keyper ADR-0011 §B)schemaBytes- the schema body bytes; UTF-8 JSON for Avro/JSON, binary for Protobuf; must be non-nulltype- the schema type (AVRO / PROTOBUF / JSON)- Returns:
- the registry-assigned global ID
-
fetchByGlobalId
Description copied from interface:SchemaRegistryClientFetches a schema by registry global ID.- Specified by:
fetchByGlobalIdin interfaceSchemaRegistryClient- Parameters:
globalId- the global ID returned by a priorSchemaRegistryClient.register(java.lang.String, byte[], com.aim2be.platform.schema.SchemaRegistryClient.SchemaType)call- Returns:
- the schema record, or
nullif no such globalId. Sentinel-field contract: the Apicurio v2 REST API has no directglobalId → (subject, version)lookup, so impls that hydrate via the content-by-globalId endpoint return aSchemaRegistryClient.Schemawithsubject=""andversion=0as sentinels. Callers that need subject/version coordinates must useSchemaRegistryClient.fetchLatestBySubject(String)instead.
-
fetchLatestBySubject
Description copied from interface:SchemaRegistryClientFetches the latest schema body registered undersubject.- Specified by:
fetchLatestBySubjectin interfaceSchemaRegistryClient- Parameters:
subject- the subject name- Returns:
- the schema record, or
nullif no such subject
-
kind
Description copied from interface:SchemaRegistryClientReturns the implementation kind. Used for observability tagging (the kind shows up asschema.registryon every OTel span this client emits) and for callers that need to choose between Apicurio globalId semantics and Confluent schemaId semantics in their producer code path.- Specified by:
kindin interfaceSchemaRegistryClient- Returns:
- the implementation kind; never null
-
wireFormat
Description copied from interface:SchemaRegistryClientReturns the wire format this client emits / parses. Defaults toWireFormat.APICURIO_8_BYTE— the Apicurio native prefix.ConfluentWireCompatSchemaRegistryClientoverrides this toWireFormat.CONFLUENT_4_BYTE.- Specified by:
wireFormatin interfaceSchemaRegistryClient- Returns:
- the wire format; never null
-