Topic Naming Validation via Regex

ahabel Member Posts: 9 ✭✭

Hi Solace Community,

I wonder if anyone else before had the need to validate topic names (including wildcards), for example in CI/CD pipelines.

Because I couldn't find anything, I've tried myself to assemble a regex that validates the general structure of topic names. By no means I feel like it's perfect, however at least it matches my few examples.

In this case I assume that topic parts should only contain small characters plus numbers and "_" or "-"




I'd really like to get your feedback if you have something better in place :-)

Maybe there's even something officially available?





  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 474 admin

    ouuh interesting! I personally have not seen a tool that is dedicated to topic validation, however I think this could be a good project for the Thinking out loud, this could be a library or a utility to validate topic prior to publishing (similar to schema validation). Curious to know what other use-cases this could have (apart from the CI/CD usecase you mentioned).

    I'm interested to hear from others in the community as well if they have developed a Soalce topic validator, any use-cases, or if anyone would find this helpful?

  • ChristianHoltfurth
    ChristianHoltfurth Member, Employee Posts: 67 Solace Employee
    edited February 2022 #3

    Hi @ahabel,

    I love the idea of this (as I love RegEx) and I feel like this should be achievable and possibly someone has something already out there. I wanted to have a stab at this myself, just haven't found the time (yet).

    Just some thoughts on your RegEx:

    • While sticking to lower case ascii is probably a good idea, it's not really required by Solace. Solace supports the full UTF-8 character set and users in APAC will probably find it useful to be able to use Chinese, Japanese, Korean or similar as part of their topic names.
    • I would mainly exclude the use of wildcard characters like "*" and ">" for SMF or "+" and "#" for MQTT in the topic as they can cause issues when trying to match your subscriptions to those topics.
    • Another one to check for is the overall topic length not being larger than 255 characters.