Class EmgMessageParser

java.lang.Object
com.eqixiac.equinix.messaging.EmgMessageParser

public final class EmgMessageParser extends Object
Parses Equinix Messaging Gateway message bodies into typed EmgMessages. Transport agnostic: feed it the bytes of an AMQP message from any client. Thread-safe and stateless.

Tolerance

  • Attribute names are matched case-insensitively; unknown attributes are ignored.
  • Unknown enum values read as UNKNOWN; timestamps without an offset are read as UTC; an unparseable timestamp reads as null; numbers sent as strings are accepted.
  • Unescaped control characters inside strings are accepted (the documented IBX sample has a line break inside Signature).
  • Task (and Body) may arrive as a JSON-encoded string rather than an object; Equinix's own Java template decodes Task that way, so both forms are accepted.
  • An unrecognised Task.Resource, or a body that does not fit its resource's model, yields an UnknownNotification rather than an error.
Only input that is not an envelope at all raises EmgParseException.

Routing

The message type is chosen from Task.Resource as in the AsyncAPI spec's conditional schemas, refined by body shape where the spec and the documented samples disagree: DataCenter.Network.Port/.VirtualConnection with a Fabric-shaped body (a data attribute) is a FabricNotification, otherwise a NetworkNotification; an order-family resource whose body has LineDetails is a BillingNotification, one with ActivityId an OrderNotification.
  • Constructor Details

    • EmgMessageParser

      public EmgMessageParser()
      Creates a parser.
  • Method Details

    • parse

      public EmgMessage parse(byte[] body)
      Parses a UTF-8 encoded message body.
      Parameters:
      body - the AMQP message body
      Returns:
      the typed message, never null
      Throws:
      EmgParseException - if the input is not an EMG envelope
    • parse

      public EmgMessage parse(String json)
      Parses a message body.
      Parameters:
      json - the message JSON
      Returns:
      the typed message, never null
      Throws:
      EmgParseException - if the input is not an EMG envelope