Table of Contents

Class MqttTopicProcessor

Namespace
Azure.Iot.Operations.Protocol
Assembly
Azure.Iot.Operations.Protocol.dll

Static class holding methods for processing MQTT topics, filters, and patterns.

public static class MqttTopicProcessor
Inheritance
MqttTopicProcessor
Inherited Members

Methods

DoesTopicMatchFilter(string, string)

public static bool DoesTopicMatchFilter(string topic, string filter)

Parameters

topic string
filter string

Returns

bool

GetReplacementMap(string, string)

public static Dictionary<string, string> GetReplacementMap(string pattern, string topic)

Parameters

pattern string
topic string

Returns

Dictionary<string, string>

ResolveTopic(string, IReadOnlyDictionary<string, string>?)

Get an MQTT topic string for publication.

public static string ResolveTopic(string pattern, IReadOnlyDictionary<string, string>? tokenMap1 = null)

Parameters

pattern string

The pattern whose tokens to replace.

tokenMap1 IReadOnlyDictionary<string, string>

A first replacement map for replacing tokens in the provided pattern.

Returns

string

The MQTT topic for publication.

Exceptions

ArgumentException

Thrown if the topic pattern is null or empty.

ValidateTopicPattern(string?, IReadOnlyDictionary<string, string>?, bool, out string, out string?, out string?)

Validates that a topic pattern is valid for use in a Command or Telemetry.

public static PatternValidity ValidateTopicPattern(string? pattern, IReadOnlyDictionary<string, string>? tokenMap, bool requireReplacement, out string errMsg, out string? errToken, out string? errReplacement)

Parameters

pattern string

The topic pattern.

tokenMap IReadOnlyDictionary<string, string>

An optional token replacement map.

requireReplacement bool

True if a replacement value is required for any token in the pattern.

errMsg string

Out parameter to receive error message if validation fails.

errToken string

Out parameter to receive the value of a missing or invalid token, if any.

errReplacement string

Out parameter to receive the value of a missing or invalid replacement, if any.

Returns

PatternValidity

A PatternValidity value indicating whether the pattern is valid or the way in which it is invalid.