Hi!
I have played around with topic filtering for a while and I think, that it would be really helpful, if we could add some new wildcards for topic filtering on broker side:
WILDCARDS:
+, #, *, -
1. WILDCARD + (filter single section of a topic)
Just used. Example
Topics:
/a/b/c/d
/a/x/c/d
/a/x/y/d
/a/e/f/g
/a/h/f/i
client(id=123).subscribe.topic("/a/+/c/d")
Results:
/a/b/c/d
/a/x/c/d
client(id=123).subscribe.topic("/a/+/+/d")
Results:
/a/x/y/d
client(id=123).subscribe.topic("/a/+/f/+")
Results:
/a/e/f/g
/a/h/f/i
2. WILDCARD # (for many sections at the end of a topic)
Just used. Example
client(id=123).subscribe.topic("/a/x/#")
Results:
/a/x/c/d
/a/x/y/d
3. WILDCARD # (for many sections IN a topic)
Example:
Topics:
/a/h/i/d
/a/k/l/m/d
client(id=123).subscribe.topic("/a/#/d")
Results:
/a/b/c/d
/a/h/i/d
/a/k/l/m/d
I have very often the use case, that I am interested in a special value, e.g. temperatures in a building, so I wanna subscribe to /house/#/temperature without the knowledge of alls the sections between /house and /temperature (because I the numbers of sections are different).
4. WILDCARD * (single character in a topic section)
Example:
Topics:
/house/flat01/room01/temperature
/house/flat01/room02/temperature
/house/flat01/room13/temperature
/house/flat01/oven/temperature
client(id=123).subscribe.topic("/house/flat01/room0*/temperature")
Results:
/house/flat01/room01/temperature
/house/flat01/room02/temperature
5. WILDCARD + (many characters in topic section)
client.(id=123).subscibe.topic("/house/flat01/room+/temperature")
Results:
/house/flat01/room01/temperature
/house/flat01/room02/temperature
/house/flat01/room13/temperature
6. "WILDCARD" - (get messages without payload)
I wanna get some information like
- Is there currently a message for a specific topic in the queue of the broker?
- How many messages for a specific topic are in the queue of the broker? (Should I download them now or later?)
- What kind of topics are currently in the queue of the broker (like topic discovery)?
Example:
client(id=123).subscribe.topic("/house/#/-")
As a results I will get empty messages for those topics without any payload:
/house/flat01/room01/temperature
/house/flat01/room02/temperature
/house/flat01/room13/temperature
/house/flat01/oven/temperature
That I know, that currently messages for these topics are available and I can chosse, which topic I wanna subscribe to (discovery).
client(id=123).subscibe.topic("/house/flat01/room04/temperature/-")
Result:
client(id=123).subscribe.topic("/house/float01/room01/temperature/-")
Results:
/house/flat01/room01/temperature
message 1
message 2
message 3
message 4
So I know, that there are messages for this topics and that there are four messages. (E.g. I could decide to start the subscription later if there are enough messages in the queue.)
Why I don't use the filter with payload? I wanna let the messages in the queue. And I don't want to have all the network traffic for downloading large payloads I am not interested in, because I am only interested to know, what kind of topics exists and after that choose those one I wanna really subscribe to.
Any feedback?
Best
Stefan