Create a QoS flow tracker.
Maximum concurrent outbound QoS > 0 messages
Get current inbound QoS 2 flow count.
Get current outbound flow count.
Check if we can send another QoS > 0 message.
true if under receive maximum
Clear all flows.
Get all inbound flows (for session persistence).
Get all outbound flows (for session persistence).
Get flows that need retry (exceeded timeout).
Retry timeout in milliseconds
Current timestamp
Array of flows needing retry
Handle PUBACK for outbound QoS 1.
PUBACK packet received
Result with completed flow or error
Handle PUBCOMP for outbound QoS 2 (step 4).
Completes the QoS 2 flow.
PUBCOMP packet received
Result with completed flow or error
Handle PUBREC for outbound QoS 2 (step 2).
Transitions flow from awaiting-pubrec to awaiting-pubcomp.
PUBREC packet received
Timestamp for retry tracking
Result with updated flow or error
Handle PUBREL for inbound QoS 2 (step 3).
Completes the inbound QoS 2 flow.
PUBREL packet received
The completed flow or undefined if not found
Check if we have an inbound QoS 2 flow for a packet ID.
Used to detect duplicate QoS 2 PUBLISH.
Increment retry count for an outbound flow.
Packet ID to update
New send timestamp
Updated flow or undefined if not found
Restore flows from session state.
Start tracking an outbound QoS 1 flow.
PUBLISH packet being sent
Send timestamp
Start tracking an inbound QoS 2 flow.
Called when we receive a QoS 2 PUBLISH and send PUBREC.
PUBLISH packet received
Receive timestamp
Start tracking an outbound QoS 2 flow.
PUBLISH packet being sent
Send timestamp
Tracks QoS message flows for reliable delivery.
Maintains separate maps for outbound (client→server) and inbound (server→client) flows. Enforces receive maximum for flow control.
Example