Class MqttClient
- All Implemented Interfaces:
MutinyDelegate
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- See Also:
-
MqttClient
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMqttClient(io.vertx.mqtt.MqttClient delegate) Create a new instance ofMqttClientdelegating to the given (non-null) instance ofMqttClient.MqttClient(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>authenticationExchange(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.voidauthenticationExchangeAndAwait(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.authenticationExchangeAndForget(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.Sets a handler that will be called when the server sends an AUTH packet (MQTT 5.0 Enhanced Authentication, see §3.15).clientId()closeHandler(Runnable closeHandler) Set a handler that will be called when the connection with server is closedio.smallrye.mutiny.Uni<MqttConnAckMessage>Connects to an MQTT server calling connectHandler after connectionio.smallrye.mutiny.Uni<MqttConnAckMessage>Connects to an MQTT server calling connectHandler after connectionio.smallrye.mutiny.Uni<MqttConnAckMessage>Connects to an MQTT server calling connectHandler after connectionconnectAndAwait(int port, String host) Connects to an MQTT server calling connectHandler after connectionconnectAndAwait(int port, String host, String serverName) Connects to an MQTT server calling connectHandler after connectionConnects to an MQTT server calling connectHandler after connectionconnectAndForget(int port, String host) Connects to an MQTT server calling connectHandler after connectionconnectAndForget(int port, String host, String serverName) Connects to an MQTT server calling connectHandler after connectionConnects to an MQTT server calling connectHandler after connectionstatic MqttClientReturn an MQTT client instance using the default optionsstatic MqttClientReturn an MQTT client instanceio.smallrye.mutiny.Uni<Void>Disconnects from the MQTT servervoidDisconnects from the MQTT serverDisconnects from the MQTT serverSets a handler that will be called when the server sends a DISCONNECT packet.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler for the client, that will be called when an error happens in internal netty structures.io.vertx.mqtt.MqttClientGet the delegate instance.inthashCode()booleanstatic MqttClientnewInstance(io.vertx.mqtt.MqttClient delegate) Creates a new instance of theMqttClient.voidpause()Pause the reading channel, so no new byte are read from the server.ping()This method is needed by the client in order to avoid server closes the connection due to the keep alive timeout if client has no messages to sendpingResponseHandler(Runnable pingResponseHandler) Sets handler which will be called after PINGRESP packet receivingio.smallrye.mutiny.Uni<Integer>publish(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDio.smallrye.mutiny.Uni<Integer>publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverSets a handler which will be called each time a PUBACK is received from the server.publishAndAwait(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDpublishAndAwait(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverpublishAndForget(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDpublishAndForget(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverpublishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler) Sets a handler which will be called when the client does not receive a PUBACK or PUBREC/PUBCOMP for a message published using QoS 1 or 2 respectively.publishCompletionHandler(Consumer<Integer> publishCompletionHandler) Sets a handler which will be called each time the publishing of a message has been completed.publishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler) Sets a handler which will be called when the client receives a PUBACK/PUBREC/PUBCOMP with an unknown packet ID.Sets a handler which will be called each time a PUBCOMP is received from the server.publishHandler(Consumer<MqttPublishMessage> publishHandler) Sets handler which will be called each time server publish something to clientSets a handler which will be called each time a PUBREC is received from the server.io.smallrye.mutiny.Uni<Void>publishRelease(int publishMessageId) Sends the PUBREL message to the remote MQTT server.voidpublishReleaseAndAwait(int publishMessageId) Sends the PUBREL message to the remote MQTT server.publishReleaseAndForget(int publishMessageId) Sends the PUBREL message to the remote MQTT server.voidresume()Resume the reading channel. seepause()Available after connection is established.io.smallrye.mutiny.Uni<Integer>Subscribes to the topic with a specified QoS levelio.smallrye.mutiny.Uni<Integer>Subscribes to the topics with related QoS levelssubscribeAndAwait(String topic, int qos) Subscribes to the topic with a specified QoS levelsubscribeAndAwait(Map<String, Integer> topics) Subscribes to the topics with related QoS levelssubscribeAndForget(String topic, int qos) Subscribes to the topic with a specified QoS levelsubscribeAndForget(Map<String, Integer> topics) Subscribes to the topics with related QoS levelssubscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler) Sets handler which will be called after SUBACK packet receivingtoString()io.smallrye.mutiny.Uni<Integer>unsubscribe(String topic) Unsubscribe from receiving messages on given topicio.smallrye.mutiny.Uni<Integer>unsubscribe(List<String> topics) Unsubscribe from receiving messages on given list of topicunsubscribeAndAwait(String topic) Unsubscribe from receiving messages on given topicunsubscribeAndAwait(List<String> topics) Unsubscribe from receiving messages on given list of topicunsubscribeAndForget(String topic) Unsubscribe from receiving messages on given topicunsubscribeAndForget(List<String> topics) Unsubscribe from receiving messages on given list of topicunsubscribeCompletionHandler(Consumer<Integer> unsubscribeCompletionHandler) Sets handler which will be called after UNSUBACK packet receivingunsubscribeCompletionMessageHandler(Consumer<MqttUnsubAckMessage> unsubscribeCompletionMessageHandler) Sets handler which will be called after UNSUBACK packet receiving
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
MqttClient
public MqttClient(io.vertx.mqtt.MqttClient delegate) Create a new instance ofMqttClientdelegating to the given (non-null) instance ofMqttClient. -
MqttClient
-
-
Method Details
-
getDelegate
public io.vertx.mqtt.MqttClient getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate instance
-
connect
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT server- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.connect(int, String)
-
connectAndAwait
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT server- Returns:
- The operation result
- See Also:
-
MqttClient.connect(int, String)
-
connectAndForget
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method ignores the
MqttConnAckMessageresult or any failure.- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT server- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.connect(int, String)
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host, String serverName) Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server name- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.connect(int, String, String)
-
connectAndAwait
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server name- Returns:
- The operation result
- See Also:
-
MqttClient.connect(int, String, String)
-
connectAndForget
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method ignores the
MqttConnAckMessageresult or any failure.- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server name- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.connect(int, String, String)
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host, String serverName, Map<String, String> userProperties) Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server nameuserProperties- Connect User Properties- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.connect(int, String, String, Map)
-
connectAndAwait
public MqttConnAckMessage connectAndAwait(int port, String host, String serverName, Map<String, String> userProperties) Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server nameuserProperties- Connect User Properties- Returns:
- The operation result
- See Also:
-
MqttClient.connect(int, String, String, Map)
-
connectAndForget
public MqttClient connectAndForget(int port, String host, String serverName, Map<String, String> userProperties) Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method ignores the
MqttConnAckMessageresult or any failure.- Parameters:
port- port of the MQTT serverhost- hostname/ip address of the MQTT serverserverName- the SNI server nameuserProperties- Connect User Properties- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.connect(int, String, String, Map)
-
disconnect
Disconnects from the MQTT serverUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.disconnect()
-
disconnectAndAwait
public void disconnectAndAwait()Disconnects from the MQTT serverUnlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
MqttClient.disconnect()
-
disconnectAndForget
Disconnects from the MQTT serverUnlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.disconnect()
-
publish
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
-
publishAndAwait
public Integer publishAndAwait(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- The operation result
- See Also:
-
MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
-
publishAndForget
public MqttClient publishAndForget(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
topic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
-
publish
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> publish(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
id- the message IDtopic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
-
publishAndAwait
public Integer publishAndAwait(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
id- the message IDtopic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- The operation result
- See Also:
-
MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
-
publishAndForget
public MqttClient publishAndForget(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT server with a specific message IDUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
id- the message IDtopic- topic on which the message is publishedpayload- message payloadqosLevel- QoS levelisDup- if the message is a duplicateisRetain- if the message needs to be retained- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
-
publishRelease
Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expiresUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.publishRelease(int)
-
publishReleaseAndAwait
public void publishReleaseAndAwait(int publishMessageId) Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expiresUnlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- See Also:
-
MqttClient.publishRelease(int)
-
publishReleaseAndForget
Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expiresUnlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
publishMessageId- identifier of the PUBLISH message to acknowledge- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.publishRelease(int)
-
subscribe
Subscribes to the topic with a specified QoS levelUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topic- topic you subscribe onqos- QoS level- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.subscribe(String, int)
-
subscribeAndAwait
Subscribes to the topic with a specified QoS levelUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topic- topic you subscribe onqos- QoS level- Returns:
- The operation result
- See Also:
-
MqttClient.subscribe(String, int)
-
subscribeAndForget
Subscribes to the topic with a specified QoS levelUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
topic- topic you subscribe onqos- QoS level- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.subscribe(String, int)
-
subscribe
Subscribes to the topics with related QoS levelsUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topics- topics and related QoS levels to subscribe to- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.subscribe(Map)
-
subscribeAndAwait
Subscribes to the topics with related QoS levelsUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topics- topics and related QoS levels to subscribe to- Returns:
- The operation result
- See Also:
-
MqttClient.subscribe(Map)
-
subscribeAndForget
Subscribes to the topics with related QoS levelsUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
topics- topics and related QoS levels to subscribe to- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.subscribe(Map)
-
unsubscribe
Unsubscribe from receiving messages on given topicUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topic- Topic you want to unsubscribe from- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.unsubscribe(String)
-
unsubscribeAndAwait
Unsubscribe from receiving messages on given topicUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topic- Topic you want to unsubscribe from- Returns:
- The operation result
- See Also:
-
MqttClient.unsubscribe(String)
-
unsubscribeAndForget
Unsubscribe from receiving messages on given topicUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
topic- Topic you want to unsubscribe from- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.unsubscribe(String)
-
unsubscribe
Unsubscribe from receiving messages on given list of topicUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topics- list of topics you want to unsubscribe from- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.unsubscribe(List)
-
unsubscribeAndAwait
Unsubscribe from receiving messages on given list of topicUnlike the bare Vert.x variant, this method returns a
Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topics- list of topics you want to unsubscribe from- Returns:
- The operation result
- See Also:
-
MqttClient.unsubscribe(List)
-
unsubscribeAndForget
Unsubscribe from receiving messages on given list of topicUnlike the bare Vert.x variant, this method ignores the
Integerresult or any failure.- Parameters:
topics- list of topics you want to unsubscribe from- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.unsubscribe(List)
-
authenticationExchange
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> authenticationExchange(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
reasonCode- authenticate reason codeproperties- MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
-
authenticationExchangeAndAwait
public void authenticationExchangeAndAwait(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
reasonCode- authenticate reason codeproperties- MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)- See Also:
-
MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
-
authenticationExchangeAndForget
public MqttClient authenticationExchangeAndForget(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties) Send an AUTH packet to the server.Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
reasonCode- authenticate reason codeproperties- MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)- Returns:
- The current instance to chain operations if needed.
- See Also:
-
MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
-
create
Return an MQTT client instance- Parameters:
vertx- Vert.x instanceoptions- MQTT client options- Returns:
- MQTT client instance
-
create
Return an MQTT client instance using the default options- Parameters:
vertx- Vert.x instance- Returns:
- MQTT client instance
-
publishCompletionHandler
Sets a handler which will be called each time the publishing of a message has been completed.For a message that has been published using
- QoS 0 this means that the client has successfully sent the corresponding PUBLISH packet,
- QoS 1 this means that a corresponding PUBACK has been received from the server,
- QoS 2 this means that a corresponding PUBCOMP has been received from the server.
- Parameters:
publishCompletionHandler- handler called with the packetId- Returns:
- current MQTT client instance
-
publishAckMessageHandler
Sets a handler which will be called each time a PUBACK is received from the server.MQTT 5.0: the handler receives the full typed message including reason code and properties. This handler fires alongside the existing
#publishCompletionHandler(Handler).- Parameters:
handler- handler called with the PUBACK message- Returns:
- current MQTT client instance
-
publishRecMessageHandler
Sets a handler which will be called each time a PUBREC is received from the server.MQTT 5.0: the handler receives the full typed message including reason code and properties, before the client sends PUBREL.
- Parameters:
handler- handler called with the PUBREC message- Returns:
- current MQTT client instance
-
publishCompMessageHandler
Sets a handler which will be called each time a PUBCOMP is received from the server.MQTT 5.0: the handler receives the full typed message including reason code and properties. This handler fires alongside the existing
#publishCompletionHandler(Handler).- Parameters:
handler- handler called with the PUBCOMP message- Returns:
- current MQTT client instance
-
publishCompletionExpirationHandler
public MqttClient publishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler) Sets a handler which will be called when the client does not receive a PUBACK or PUBREC/PUBCOMP for a message published using QoS 1 or 2 respectively.The time to wait for an acknowledgement message can be configured using
MqttClientOptions.setAckTimeout(int). If the client receives a PUBACK/PUBREC/PUBCOMP for a message after its completion has expired, the handler registered using#publishCompletionUnknownPacketIdHandler(Handler)will be invoked.Note that this behavior is outside the scope of the MQTT 3.1.1 specification. The client's default behavior is therefore to wait forever for the server's corresponding acknowledgement.
- Parameters:
publishCompletionExpirationHandler- the handler to call with the ID of the expired packet- Returns:
- current MQTT client instance
-
publishCompletionUnknownPacketIdHandler
public MqttClient publishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler) Sets a handler which will be called when the client receives a PUBACK/PUBREC/PUBCOMP with an unknown packet ID.- Parameters:
publishCompletionPhantomHandler- the handler to call with the unknown packet ID- Returns:
- current MQTT client instance
-
publishHandler
Sets handler which will be called each time server publish something to client- Parameters:
publishHandler- handler to call- Returns:
- current MQTT client instance
-
subscribeCompletionHandler
public MqttClient subscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler) Sets handler which will be called after SUBACK packet receiving- Parameters:
subscribeCompletionHandler- handler to call. List inside is a granted QoS array- Returns:
- current MQTT client instance
-
unsubscribeCompletionHandler
Sets handler which will be called after UNSUBACK packet receiving- Parameters:
unsubscribeCompletionHandler- handler to call with the packetid- Returns:
- current MQTT client instance
-
unsubscribeCompletionMessageHandler
public MqttClient unsubscribeCompletionMessageHandler(Consumer<MqttUnsubAckMessage> unsubscribeCompletionMessageHandler) Sets handler which will be called after UNSUBACK packet receiving- Parameters:
unsubscribeCompletionMessageHandler- handler to call with the unsubscribe message- Returns:
- current MQTT client instance
-
pingResponseHandler
Sets handler which will be called after PINGRESP packet receiving- Parameters:
pingResponseHandler- handler to call- Returns:
- current MQTT client instance
-
exceptionHandler
Set an exception handler for the client, that will be called when an error happens in internal netty structures.io.netty.handler.codec.DecoderExceptioncan be one of the cause- Parameters:
handler- the exception handler- Returns:
- current MQTT client instance
-
disconnectMessageHandler
Sets a handler that will be called when the server sends a DISCONNECT packet.This fires before
#closeHandler(Handler)and only for server-initiated disconnects (not when the client callsdisconnect()). The handler receives the reason code and properties from the server's DISCONNECT packet.- Parameters:
handler- handler to call with the disconnect message- Returns:
- current MQTT client instance
-
authenticationExchangeHandler
public MqttClient authenticationExchangeHandler(Consumer<MqttAuthenticationExchangeMessage> handler) Sets a handler that will be called when the server sends an AUTH packet (MQTT 5.0 Enhanced Authentication, see §3.15).The handler receives the reason code, the authentication method, the authentication data and the full set of MQTT properties from the server's AUTH packet. The user can then reply with
authenticationExchange(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode, io.netty.handler.codec.mqtt.MqttProperties).- Parameters:
handler- handler to call with the AUTH message- Returns:
- current MQTT client instance
-
closeHandler
Set a handler that will be called when the connection with server is closed- Parameters:
closeHandler- handler to call- Returns:
- current MQTT client instance
-
ping
This method is needed by the client in order to avoid server closes the connection due to the keep alive timeout if client has no messages to send- Returns:
- current MQTT client instance
-
pause
public void pause()Pause the reading channel, so no new byte are read from the server. Available after connection is established.This simply delegates to
NetSocket.pause(). -
resume
public void resume()Resume the reading channel. seepause()Available after connection is established.This simply delegates to
NetSocket.resume(). -
clientId
- Returns:
- the client identifier
-
isConnected
public boolean isConnected()- Returns:
- if the connection between client and remote server is established/open
-
newInstance
Creates a new instance of theMqttClient. -
hashCode
public int hashCode() -
equals
-
toString
-