File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed
src/main/java/com/hivemq/client
internal/mqtt/message/publish Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,11 @@ public abstract class MqttPublishBuilder<B extends MqttPublishBuilder<B>> {
104104 }
105105
106106 public @ NotNull B messageExpiryInterval (final long messageExpiryInterval ) {
107- this .messageExpiryInterval = Checks .unsignedInt (messageExpiryInterval , "Message expiry interval" );
107+ if (messageExpiryInterval == -1 ) {
108+ this .messageExpiryInterval = MqttPublish .NO_MESSAGE_EXPIRY ;
109+ } else {
110+ this .messageExpiryInterval = Checks .unsignedInt (messageExpiryInterval , "Message expiry interval" );
111+ }
108112 return self ();
109113 }
110114
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public interface Mqtt5ConnectBuilderBase<B extends Mqtt5ConnectBuilderBase<B>> {
6969 /**
7070 * Sets the {@link Mqtt5Connect#getSessionExpiryInterval() session expiry interval} in seconds.
7171 * <p>
72- * The value must be in the range of an unsigned int: [0, 4_294_967_295].
72+ * The value must be in the range of an unsigned int: [0, 4_294_967_295]. 4_294_967_295 disables session expiry.
7373 *
7474 * @param sessionExpiryInterval the session expiry interval in seconds.
7575 * @return the builder.
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ interface Complete<C extends Mqtt5PublishBuilderBase.Complete<C>> extends Mqtt5P
116116 /**
117117 * Sets the {@link Mqtt5Publish#getMessageExpiryInterval() message expiry interval} in seconds.
118118 * <p>
119- * The value must be in the range of an unsigned int: [0, 4_294_967_295].
119+ * The value must be in the range of an unsigned int: [0, 4_294_967_295] or -1 to disable message expiry .
120120 *
121121 * @param messageExpiryInterval the message expiry interval in seconds.
122122 * @return the builder.
You can’t perform that action at this time.
0 commit comments