Package com.aim2be.platform.schema
Class ApicurioSchemaRegistryClient
java.lang.Object
com.aim2be.platform.schema.ApicurioSchemaRegistryClient
- All Implemented Interfaces:
SchemaRegistryClient
Apicurio Registry implementation of
SchemaRegistryClient
(ADR-0011 §B, primary path).
Wraps a Spring-injected RegistryClient (Apicurio 2.5.x v2 REST
API) plus a configured group ID. Every method emits an OpenTelemetry
CLIENT span tagged with schema.registry=apicurio,
schema.subject, schema.global_id (when known), and
outcome=success|error.
Authentication is via mTLS through the Envoy/SPIRE sidecar (Stage B L0
Tranche-0); no in-process credential material is held by this client. The
registry URL + group ID come from SchemaRegistryProperties.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.aim2be.platform.schema.SchemaRegistryClient
SchemaRegistryClient.Kind, SchemaRegistryClient.Schema, SchemaRegistryClient.SchemaType -
Constructor Summary
ConstructorsConstructorDescriptionApicurioSchemaRegistryClient(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.io.apicurio.registry.rest.client.RegistryClientkind()Returns the implementation kind.longregister(String subject, byte[] schemaBytes, SchemaRegistryClient.SchemaType type) RegistersschemaBytesundersubject, returning the registry-assigned global ID.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.aim2be.platform.schema.SchemaRegistryClient
wireFormat
-
Constructor Details
-
ApicurioSchemaRegistryClient
public ApicurioSchemaRegistryClient(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 under which subjects live; not null. Apicurio v2 namespaces every artifact under a group; the platform default isdefaultperSchemaRegistryProperties.getGroupId().compatibility- the compatibility rule to enforce on EVERY registered artifact (BACKWARD,FORWARD,FULL,NONE; case- insensitive). Applied via Apicurio's per-artifact rule API on first registration; subsequent registrations are validated against this rule server-side. Passnullor blank to skip rule application (matches the legacy "no compatibility enforcement" behaviour).openTelemetry- OpenTelemetry instance for tracer acquisition; not null. Tests passOpenTelemetry.noop()to silence spans.
-
-
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
-
getGroupId
- Returns:
- the artifact group ID under which this client operates; never null. Useful for diagnostic logging.
-
getDelegate
public io.apicurio.registry.rest.client.RegistryClient getDelegate()- Returns:
- the underlying Apicurio v2 REST client. Exposed for the
DualSchemaRegistryClientcoordinator to share a singleRegistryClientbean across primary + fallback paths.
-