Class MqttReactiveResponder

Namespace
Kuestenlogik.Bowire.Protocol.Mqtt.Mock
Assembly
Kuestenlogik.Bowire.Protocol.Mqtt.dll

MQTT reactive matcher / responder. Watches incoming client publishes via the broker's InterceptingPublishAsync event and emits paired responses for every recorded step whose topic pattern matches.

public sealed class MqttReactiveResponder : IDisposable
Inheritance
MqttReactiveResponder
Implements
Inherited Members

Remarks

Recording shape for a reactive MQTT step:

{
  "protocol": "mqtt",
  "methodType": "Duplex",
  "method": "cmd/+/reboot",              // topic pattern with wildcards
  "metadata": {
      "responseTopic": "cmd/${topic.0}/ack",  // optional; MQTT v5 ResponseTopic on the incoming publish wins when present
      "qos": "1",
      "retain": "false"
  },
  "body": "{\"ack\":true,\"device\":\"${topic.0}\"}"
}

On match:

  1. Extract wildcard bindings via MqttTopicMatcher (+ captures by position, trailing # as ${topic.rest}).
  2. Resolve the response topic — MQTT v5 ResponseTopic on the incoming publish wins, else metadata.responseTopic from the step, else no response (fire-and-forget).
  3. Run Substitute(string, IReadOnlyDictionary<string, string>?) on both the response topic and the payload with the bindings as extras so ${topic.N} / ${topic.rest} get concrete values.
  4. Inject the response via InjectApplicationMessage(InjectedMqttApplicationMessage, CancellationToken), copying CorrelationData from the request (MQTT v5) so clients can pair request/response.

Constructors

MqttReactiveResponder(MqttServer, BowireRecording, ILogger)

public MqttReactiveResponder(MqttServer broker, BowireRecording recording, ILogger logger)

Parameters

broker MqttServer
recording BowireRecording
logger ILogger

Methods

Dispose()

public void Dispose()

Start()

Hook the broker-intercept event. Call once per emitter lifetime.

public void Start()