Skip to content

In-flight and Queue


To improve message throughput and reduce the impact of network fluctuations, EMQX allows multiple unacknowledged QoS 1 and QoS 2 packets to exist on the network link at the same time. These sent but unconfirmed packets will be stored in the Inflight Window until acknowledgment is complete.

When the number of concurrently existing packets in the network exceeds the limit, that is, the length limit of Inflight Window is reached(see max_inflight), EMQX will no longer send subsequent messages, but will store these packets in the Message Queue. Once a message is acknowledged in the Inflight Window, the message in the Message Queue will be sent in first-in, first-out order and stored in the Inflight Window.

When the client is offline, Message Queue is also used to store QoS 0 messages, which will be sent for the next time when the client is online. This feature is enabled by default, but you can also disable it manually. You can see mqueue_store_qos0 for details.

It should be noted that if the length limit of Message Queue is also reached, subsequent packets will still be buffered to the Message Queue, but the first buffered message in the corresponding message queue will be discarded. If there are QoS 0 messages in the queue, the QoS 0 messages will be discarded first. Therefore, it is very important to configure a suitable Message Queue length limit (see max_mqueue_len) according to your actual situation.

Inflight Queue and Receive Maximum

The MQTT v5.0 protocol adds a Receive Maximum attribute to CONNECT packets, and the official explanation for it is:

The client uses this value to limit the maximum number of published messages with a QoS of1 and a QoS of 2 that the client is willing to process simultaneously. There is no mechanism to limit the published messages with a QoS of 0 that the server is trying to send.

That is, the server can send subsequent PUBLISH packets to the client with different message identifiers while waiting for acknowledgment, until the number of unacknowledged messages reaches the Receive Maximum limit.

It is not difficult to see that Receive Maximum is actually the same as the Inflight Window mechanism in EMQX. However, EMQX already provided this function to the accessed MQTT client before the MQTT v5.0 protocol was released. Now, the clients using the MQTT v5.0 protocol will set the maximum length of the Inflight Window according to the specification of the Receive Maximum, while clients with earlier versions of the MQTT protocol will still set it according to the configuration.

Configuration Items

Configuration ItemsTypeOptional ValueDefault ValueDescription
max_inflightinteger>= 032 (external),
128 (internal)
Inflight Window length limit, 0 means no limit
max_mqueue_leninteger>= 01000 (external),
10000 (internal)
Message Queue length limit, 0 means no limit
mqueue_store_qos0enumtrue, falsetrueWhether EMQX store QoS 0 messages to the Message Queue when the client is offline