Class AsyncApiMessage

java.lang.Object
org.mockserver.async.asyncapi.AsyncApiMessage

public class AsyncApiMessage extends Object
Represents a single message definition within an AsyncAPI channel.

A channel may contain multiple messages (AsyncAPI 3.x channels.<n>.messages or AsyncAPI 2.x oneOf in the operation message). Each message has its own payload schema, examples, optional Kafka key binding, and optional correlation ID location.

MQTT qos/retain remain channel-level (operation binding) and are not per-message.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AsyncApiMessage(String name, com.fasterxml.jackson.databind.JsonNode payloadSchema, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, String kafkaKey)
    Backward-compatible constructor — no correlation ID.
    AsyncApiMessage(String name, com.fasterxml.jackson.databind.JsonNode payloadSchema, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, String kafkaKey, String correlationIdLocation)
    Full constructor with correlation ID location.
  • Method Summary

    Modifier and Type
    Method
    Description
    The AsyncAPI correlation ID runtime expression (e.g.
    Kafka message key from message-level bindings, or null if not derivable.
    The message name, or null for anonymous / unnamed messages.
    List<com.fasterxml.jackson.databind.JsonNode>
    Explicit examples found in the spec for this message's payload.
    com.fasterxml.jackson.databind.JsonNode
    The JSON Schema describing the payload (may be null if not present).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AsyncApiMessage

      public AsyncApiMessage(String name, com.fasterxml.jackson.databind.JsonNode payloadSchema, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, String kafkaKey)
      Backward-compatible constructor — no correlation ID.
      Parameters:
      name - the message name (nullable; e.g. the key under messages.<name> in v3)
      payloadSchema - the JSON Schema for the payload (may be null)
      payloadExamples - explicit payload examples from the spec (never null after construction)
      kafkaKey - Kafka message key from message-level bindings (may be null)
    • AsyncApiMessage

      public AsyncApiMessage(String name, com.fasterxml.jackson.databind.JsonNode payloadSchema, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, String kafkaKey, String correlationIdLocation)
      Full constructor with correlation ID location.
      Parameters:
      name - the message name (nullable; e.g. the key under messages.<name> in v3)
      payloadSchema - the JSON Schema for the payload (may be null)
      payloadExamples - explicit payload examples from the spec (never null after construction)
      kafkaKey - Kafka message key from message-level bindings (may be null)
      correlationIdLocation - the runtime expression from correlationId.location (may be null)
  • Method Details

    • getName

      public String getName()
      The message name, or null for anonymous / unnamed messages.
    • getPayloadSchema

      public com.fasterxml.jackson.databind.JsonNode getPayloadSchema()
      The JSON Schema describing the payload (may be null if not present).
    • getPayloadExamples

      public List<com.fasterxml.jackson.databind.JsonNode> getPayloadExamples()
      Explicit examples found in the spec for this message's payload.
    • getKafkaKey

      public String getKafkaKey()
      Kafka message key from message-level bindings, or null if not derivable.
    • getCorrelationIdLocation

      public String getCorrelationIdLocation()
      The AsyncAPI correlation ID runtime expression (e.g. $message.header#/correlationId or $message.payload#/metadata/id), or null if the message does not define a correlation ID.