Class SchemaDefinition

java.lang.Object
org.acemq.amqp.api.SchemaDefinition

public final class SchemaDefinition extends Object
A schema as a registry sees it: some text, and enough about it to know what the text is.

Deliberately not an Avro type, a Protobuf descriptor or a JSON Schema object. A registry that speaks one serialisation format is a registry that has to be rebuilt for the next one, and the same schemas will need to be reachable from MQTT and STOMP as much as from AMQP. The format is a label; the definition is text; parsing is the codec's business.

The fingerprint is what makes registration idempotent. Registering the same schema twice must return the same identifier however many processes do it and in whatever order, so the question "have I seen this before?" is asked of the content rather than of a name somebody chose.

  • Constructor Details

    • SchemaDefinition

      public SchemaDefinition(String format, String subject, String definition)
      Parameters:
      format - serialisation format this schema is written in, such as avro, protobuf or jsonschema
      subject - what the schema describes, normally the fully qualified type name
      definition - the schema itself, as text
  • Method Details

    • format

      public String format()
      Returns:
      the serialisation format, lowercase
    • subject

      public String subject()
      Returns:
      what the schema describes
    • definition

      public String definition()
      Returns:
      the schema text
    • fingerprint

      public String fingerprint()
      Returns:
      a hex SHA-256 over the format and the definition. Two definitions differing only in whitespace fingerprint differently, which is deliberate: canonicalising is format-specific and belongs to whoever understands the format
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object