Class MqttPublicationRefusedException

All Implemented Interfaces:
Serializable

public final class MqttPublicationRefusedException extends MqttException
The broker refused a publication, or would refuse it. A refusal arrives in PUBACK or PUBREC with a reason code of 0x80 or greater, such as ReasonCode.NOT_AUTHORIZED or ReasonCode.QUOTA_EXCEEDED; the broker did not accept the message, and the exchange is over. A publication that exceeds a limit that the broker announced for the connection is not sent at all and fails with the reason code that the broker would use: ReasonCode.QOS_NOT_SUPPORTED above ConnAck.maximumQos(), ReasonCode.RETAIN_NOT_SUPPORTED without ConnAck.retainAvailable(), and ReasonCode.PACKET_TOO_LARGE beyond ConnAck.maximumPacketSize(). A publication too large for the client to send fails with ReasonCode.PACKET_TOO_LARGE in the same way, with any broker. Either way the connection goes on. Only MQTT 5.0 brokers refuse publications or announce these limits.
See Also:
  • Constructor Details

    • MqttPublicationRefusedException

      public MqttPublicationRefusedException(ReasonCode reasonCode)
      A refusal without an explanation, such as the one that the client makes itself.
      Parameters:
      reasonCode - the reason for the refusal
    • MqttPublicationRefusedException

      public MqttPublicationRefusedException(ReasonCode reasonCode, @Nullable String reasonString)
      A refusal with the broker's explanation, if the broker sent one.
      Parameters:
      reasonCode - the reason for the refusal
      reasonString - the broker's explanation, or null when it sent none
  • Method Details

    • reasonCode

      public ReasonCode reasonCode()
      Returns the reason for the refusal, received in PUBACK or PUBREC, or the one that the broker would use for a publication that exceeds its announced limits.
      Returns:
      the reason for the refusal, received in PUBACK or PUBREC, or the one that the broker would use for a publication that exceeds its announced limits
    • reasonString

      public Optional<String> reasonString()
      Returns the broker's explanation for people diagnosing the refusal, received in PUBACK or PUBREC, or empty when the broker sent none or the client refused without sending.
      Returns:
      the broker's explanation for people diagnosing the refusal, received in PUBACK or PUBREC, or empty when the broker sent none or the client refused without sending