io.vertx.mqtt.messages

## Interface MqttPublishMessage

- All Superinterfaces:
    MqttMessage

      public interface MqttPublishMessage
      extends MqttMessage

  Represents an MQTT PUBLISH message

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `ack()` Send the PUBACK/PUBCOMP to the broker.
    `static MqttPublishMessage` | `create(int messageId, MqttQoS qosLevel, boolean isDup, boolean isRetain, String topicName, ByteBuf payload)` Create a concrete instance of a Vert.x publish message
    `static MqttPublishMessage` | `create(int messageId, MqttQoS qosLevel, boolean isDup, boolean isRetain, String topicName, ByteBuf payload, MqttProperties properties)` Create a concrete instance of a Vert.x publish message
    `boolean` | `isDup()`
    `boolean` | `isRetain()`
    `Buffer` | `payload()`
    `MqttProperties` | `properties()`
    `MqttQoS` | `qosLevel()`
    `String` | `topicName()`

    - ### Methods inherited from interface io.vertx.mqtt.messages.MqttMessage

      `messageId`

- - ### Method Detail

    - #### create

          static MqttPublishMessage create(int messageId,
                                           MqttQoS qosLevel,
                                           boolean isDup,
                                           boolean isRetain,
                                           String topicName,
                                           ByteBuf payload)

      Create a concrete instance of a Vert.x publish message
      Parameters:
        `messageId` - message identifier
        `qosLevel` - quality of service level
        `isDup` - if the message is a duplicate
        `isRetain` - if the message needs to be retained
        `topicName` - topic on which the message was published
        `payload` - payload message
      Returns:
        Vert.x publish message

    - #### create

          static MqttPublishMessage create(int messageId,
                                           MqttQoS qosLevel,
                                           boolean isDup,
                                           boolean isRetain,
                                           String topicName,
                                           ByteBuf payload,
                                           MqttProperties properties)

      Create a concrete instance of a Vert.x publish message
      Parameters:
        `messageId` - message identifier
        `qosLevel` - quality of service level
        `isDup` - if the message is a duplicate
        `isRetain` - if the message needs to be retained
        `topicName` - topic on which the message was published
        `payload` - payload message
        `properties` - message properties
      Returns:
        Vert.x publish message

    - #### qosLevel

          MqttQoS qosLevel()

      Returns:
        Quality of service level

    - #### isDup

          boolean isDup()

      Returns:
        If the message is a duplicate

    - #### isRetain

          boolean isRetain()

      Returns:
        If the message needs to be retained

    - #### topicName

          String topicName()

      Returns:
        Topic on which the message was published

    - #### payload

          Buffer payload()

      Returns:
        Payload message

    - #### ack

          void ack()

      Send the PUBACK/PUBCOMP to the broker. Use this method only if autoAck option is set to false.
      Throws:
        `IllegalStateException` - if you are ack a message (with QoS > 0) when the Auto Ack is true
        `IllegalStateException` - if the message is already ack'ed

    - #### properties

          MqttProperties properties()

      Returns:
        MQTT properties

Copyright © 2025 Eclipse. All rights reserved.