Class SchemaRegistryClient

java.lang.Object
org.mockserver.async.serde.SchemaRegistryClient

public class SchemaRegistryClient extends Object
A minimal client for the Confluent Schema Registry REST API — just the two operations MockServer needs, implemented over the JDK's HttpClient so no Confluent Community License artifacts are pulled in:
  • getSchemaById(int)GET /schemas/ids/{id}, used on the consume/verify path to resolve the schema embedded in a Confluent wire-format message.
  • register(String, String)POST /subjects/{subject}/versions, used on the publish path to obtain the schema id to frame messages with.

Both results are cached: schema-by-id is immutable, and a (subject, schema) registration is idempotent and returns a stable id, so repeated publishes do not re-hit the registry.

  • Constructor Details

    • SchemaRegistryClient

      public SchemaRegistryClient(String baseUrl)
  • Method Details

    • getSchemaById

      public String getSchemaById(int id)
      Resolve an Avro schema's JSON text by its registered id.
      Parameters:
      id - the schema id embedded in a Confluent wire-format message
      Returns:
      the Avro schema JSON text
    • register

      public int register(String subject, String schemaJson)
      Register (idempotently) an Avro schema under the given subject and return its id.
      Parameters:
      subject - the registry subject (typically <topic>-value)
      schemaJson - the Avro schema JSON text
      Returns:
      the registered schema id