Topic strings and topic filters in MQTT clients

Topic strings and topic filters are used to publish and to subscribe. The syntax of topic strings and filters in MQTT clients is largely the same as topic strings in IBM® MQ.

Topics strings are used to send publications to subscribers. Create a topic string using the method, MqttClient.getTopic(java.lang.String topicString).

Topic filters are used to subscribe to topics and receive publications. Topic filters can contain wildcards. With wildcards, you can subscribe to multiple topics. Create a topic filter by using a subscription method; for example, MqttClient.subscribe(java.lang.String topicFilter).

Topic strings

The syntax of an IBM MQ topic string is described in Topic Strings. The syntax of MQTT topic strings is described in the MqttClient class in the API documentation for the MQTT client for Java. For links to client API documentation for the MQTT client libraries, see MQTT client programming reference.

The syntax of each type of topic string is almost identical. There are four minor differences:
  1. Topic strings sent to IBM MQ by MQTT clients must follow the convention for queue manager names.
  2. The maximum lengths differ. IBM MQ topic strings are limited to 10,240 characters. An MQTT client can create topic strings of up to 65535 bytes.
  3. A topic string created by an MQTT client cannot contain a null character.
  4. In IBM Integration Bus, a null topic level, '...//...' is invalid. Null topic levels are supported by IBM MQ.

Unlike IBM MQ publish/subscribe, the mqttv3 protocol does not have a concept of an administrative topic object. You cannot construct a topic string from a topic object and a topic string. However, a topic string is mapped to an administrative topic in IBM MQ. The access control associated with the administrative topic determines whether a publication is published to the topic, or discarded. The attributes that are applied to a publication when it is forwarded to subscribers, are influenced by the attributes of the administrative topic.

Topic filters

The syntax of an IBM MQ topic filter is described in Topic-based wildcard scheme. The syntax of the topic filters you can construct with an MQTT client are described in the MqttClient class in the API documentation for the MQTT client for Java. For links to client API documentation for the MQTT client libraries, see MQTT client programming reference.