In MQTT, quality of service (QoS) controls the assurance of message delivery over the underlying transport. IBM® Integration Bus handles messages in different ways, depending on whether the QoS level is 0, 1, or 2.
When IBM Integration Bus connects to an MQTT server to publish a message with QoS 1 or QoS 2, or to subscribe to a topic with QoS 1 or QoS 2, the clean session flag is set to 0 (false). Therefore, any messages that are in flight when a connection is lost are delivered when IBM Integration Bus reconnects to the server.
The QoS level for received messages applies only to the transfer of the messages from the MQTT server to IBM Integration Bus. When a message with QoS 0 is successfully received by the Paho client, the MQTTSubscribe node propagates the message to the Out terminal. When a message with QoS 1 or QoS 2 is successfully received, the Paho client must acknowledge the receipt of the message before it can be processed by the node. After the transfer is successfully acknowledged and completed, the QoS level has no further effect on how the message is handled by IBM Integration Bus.
If the network connection to the MQTT server is lost, the MQTTSubscribe node retries the connection after 5 seconds. The interval between reconnection attempts increases by 5 seconds on each attempt, up to a maximum of 2 minutes. There is no limit to the number of reconnection attempts. These attempts are logged in the MQTT Activity log.
If messages arrive faster than they can be processed by IBM Integration Bus, message receipt is blocked until the message flow is able to process them.
When an MQTTSubscribe node receives a message, the local environment is populated with the QoS of the message by using the QualityOfService variable. For more information about the local environment variables, see MQTTSubscribe node.
The QoS level for published messages applies to the transfer of the message from IBM Integration Bus to the MQTT server. When the MQTTPublish node publishes a message with QoS 0, an acknowledgment of the transfer is not expected. When the MQTTPublish node publishes a message with QoS 1 or QoS 2, the node waits for up to 30 seconds for the Paho client to confirm that the MQTT server has acknowledged receipt of the message. If no acknowledgment is received after this time, the node retries the publish. If this second attempt fails, an exception is produced with message BIP12099, and the node propagates the message to the Failure terminal if the node has a Failure terminal connected. If a Failure terminal is not connected, the message is rolled back to the input node.
A connection failure at the network level generates an exception with message BIP12096. The MQTT resource statistics measurement FailedConnections, which reports the total number of attempted connections to an MQTT server that have failed since the last integration server restart, is also incremented.