OutgoingMessages Property

Collection of outgoing messages with QoS > 0 that have not been fully acknowledged.

Syntax

public MQTTMessageList getOutgoingMessages();

Remarks

Each time the class publishes a message with a QoS of 1 or 2, it adds it to the OutgoingMessages collection after the initial PUBLISH packet is sent (this does not occur for messages publish with a QoS of 0). A message remains in the OutgoingMessages collection until the class has completed all of the acknowledgment steps required for it based on its QoS level.

Outgoing messages with a QoS of 1 follow these steps:

  1. The class sends the PUBLISH packet, then adds the message to OutgoingMessages.
  2. The class waits to receive a PUBACK (publish acknowledgment) packet.
  3. The MessageAck event is fired.
  4. The message is removed from OutgoingMessages.
  5. The MessageOut event is fired.

Outgoing messages with a QoS of 2 follow these steps:

  1. The class sends the PUBLISH packet, then adds the message to OutgoingMessages.
  2. The class waits to receive a PUBREC (publish received) packet.
  3. The class sends a PUBREL (publish release) packet in response.
  4. The class waits to receive a PUBCOMP (publish complete) packet.
  5. The MessageAck event is fired.
  6. The message is removed from OutgoingMessages.
  7. The MessageOut event is fired.

In MQTT 3.1.1, the RepublishInterval configuration setting, if set to a non-zero value (default), controls how long the class will wait to receive a PUBACK (for QoS 1) or PUBREC (for QoS 2) before automatically republishing an outgoing message. In MQTT 5, messages are only republished if the client is disconnected before receiving a PUBACK or PUBREC.

The class processes messages anytime DoEvents is called. In applications with a GUI, the DoEvents method is also typically called automatically when the class is idle. In all other situations however, it is best practice to call DoEvents in a loop when possible to ensure timely processing of messages.

This collection is indexed from 0 to size - 1.

This property is read-only and not available at design time.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks MQ 2020 Java Edition - Version 20.0 [Build 8162]