Class MqttMessageSubscriber

java.lang.Object
org.mockserver.async.subscribe.MqttMessageSubscriber
All Implemented Interfaces:
MessageSubscriber

public class MqttMessageSubscriber extends Object implements MessageSubscriber
A MessageSubscriber that uses an MQTT MqttClient to subscribe to topics and record received messages.

Recorded messages are stored in a bounded BoundedMessageStore per channel to prevent unbounded memory growth.

  • Constructor Details

    • MqttMessageSubscriber

      public MqttMessageSubscriber(String brokerUrl, String clientId)
      Create a subscriber connected to the given MQTT broker with no security. Backward-compatible entry point.
      Parameters:
      brokerUrl - the MQTT broker URL (e.g. tcp://localhost:1883)
      clientId - the client identifier
    • MqttMessageSubscriber

      public MqttMessageSubscriber(String brokerUrl, String clientId, int qos)
      Create a subscriber with a specific QoS level and no security.
    • MqttMessageSubscriber

      public MqttMessageSubscriber(String brokerUrl, String clientId, int qos, int maxRecordedMessages)
      Create a subscriber with a specific QoS level and recorded-message cap, no security. Backward-compatible entry point.
    • MqttMessageSubscriber

      public MqttMessageSubscriber(String brokerUrl, String clientId, int qos, int maxRecordedMessages, MqttSecurity security)
      Create a subscriber with optional security configuration.
      Parameters:
      brokerUrl - the MQTT broker URL (e.g. ssl://localhost:8883)
      clientId - the client identifier
      qos - the MQTT QoS level (0, 1, or 2)
      maxRecordedMessages - maximum recorded messages per channel
      security - security configuration (may be null for plaintext)
  • Method Details