Class PublishOptions

java.lang.Object
org.mockserver.async.publish.PublishOptions

public final class PublishOptions extends Object
Immutable carrier for per-message publish-time options extracted from AsyncAPI bindings.

All fields are nullable; a null value means "use the publisher default".

  • key — Kafka record key (from message.bindings.kafka.key)
  • qos — MQTT QoS level 0, 1, or 2 (from operationBindings.mqtt.qos)
  • retain — MQTT retain flag (from operationBindings.mqtt.retain)
  • headers — message headers, e.g. for correlation IDs (may be empty)
See Also:
  • Constructor Details

    • PublishOptions

      public PublishOptions(String key, Integer qos, Boolean retain)
      Backward-compatible constructor — no headers.
      Parameters:
      key - Kafka record key (may be null)
      qos - MQTT QoS level (may be null; must be 0, 1, or 2 when non-null)
      retain - MQTT retain flag (may be null)
      Throws:
      IllegalArgumentException - if qos is non-null and not in {0, 1, 2}
    • PublishOptions

      public PublishOptions(String key, Integer qos, Boolean retain, Map<String,String> headers)
      Full constructor with headers.
      Parameters:
      key - Kafka record key (may be null)
      qos - MQTT QoS level (may be null; must be 0, 1, or 2 when non-null)
      retain - MQTT retain flag (may be null)
      headers - message headers (may be null; defensively copied)
      Throws:
      IllegalArgumentException - if qos is non-null and not in {0, 1, 2}
  • Method Details

    • none

      public static PublishOptions none()
      Returns:
      a shared instance with all fields null/empty (no bindings)
    • getKey

      public String getKey()
      Returns:
      the Kafka record key, or null if not specified
    • getQos

      public Integer getQos()
      Returns:
      the MQTT QoS level (0, 1, or 2), or null if not specified
    • getRetain

      public Boolean getRetain()
      Returns:
      the MQTT retain flag, or null if not specified
    • getHeaders

      public Map<String,String> getHeaders()
      Returns:
      unmodifiable message headers (never null; empty when no headers)
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if all fields are null/empty (no bindings)
    • toString

      public String toString()
      Overrides:
      toString in class Object