Search code examples
javascriptangularmqtt

MQTT observable with wildcard in angular app


I have questions about mqtt wildcards (i am using the mosqitto broker): say i have somewhere between 1-2k topics. I run an observe (using ngx-mqtt) on them in my frontend with a single level wildcard.

  1. Is there going to be a new observable for each and every topic that is encompassed?
  2. How does the broker handle the update of the observables?
  3. Is it even advisable to publish small data for this many topics or is it better to run large payloads on less topics?

Solution

  • The broker receives a single subscription for what ever wildcard topic pattern you supply.

    Every message published to the broker is checked against that pattern, if it matches it is sent to the client.

    The client will have a single call back for that topic pattern, how it chooses to split that up is likely to be at the developers choice.

    We can't answer the last question about if fewer large message vs many small messages as we don't know anything about your data, how it is produced and consumed.