messagesMatching

Returns a Flow of messages whose topic matches the given MQTT topicFilter.

Supports MQTT wildcard patterns:

  • + matches a single topic level

  • # matches any number of remaining levels (must be last)

Example

client.messagesMatching("sensors/+/temperature").collect { msg ->
println("${msg.topic}: ${msg.payloadAsString()}")
}