Class MqttClient
- All Implemented Interfaces:
MutinyDelegate
original
non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclientId()
closeHandler
(Runnable closeHandler) io.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) Blocking variant ofconnect(int,String)
.connectAndAwait
(int port, String host, String serverName) Blocking variant ofconnect(int,String,String)
.connectAndForget
(int port, String host) Variant ofconnect(int,String)
that ignores the result of the operation.connectAndForget
(int port, String host, String serverName) Variant ofconnect(int,String,String)
that ignores the result of the operation.static MqttClient
static MqttClient
io.smallrye.mutiny.Uni<Void>
Disconnects from the MQTT server calling disconnectHandler after disconnectionBlocking variant ofdisconnect()
.Variant ofdisconnect()
that ignores the result of the operation.boolean
exceptionHandler
(Consumer<Throwable> handler) io.vertx.mqtt.MqttClient
int
hashCode()
boolean
static MqttClient
newInstance
(io.vertx.mqtt.MqttClient arg) ping()
pingResponseHandler
(Runnable pingResponseHandler) io.smallrye.mutiny.Uni<Integer>
publish
(String topic, Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Sends the PUBLISH message to the remote MQTT serverpublishAndAwait
(String topic, Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Blocking variant ofpublish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
.publishAndForget
(String topic, Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Variant ofpublish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
that ignores the result of the operation.publishCompletionExpirationHandler
(Consumer<Integer> publishCompletionExpirationHandler) publishCompletionHandler
(Consumer<Integer> publishCompletionHandler) publishCompletionUnknownPacketIdHandler
(Consumer<Integer> publishCompletionPhantomHandler) publishHandler
(Consumer<MqttPublishMessage> publishHandler) io.smallrye.mutiny.Uni<Integer>
Subscribes to the topic with a specified QoS levelio.smallrye.mutiny.Uni<Integer>
Subscribes to the topic and adds a handler which will be called after the request is sentsubscribeAndAwait
(String topic, int qos) Blocking variant ofsubscribe(String,int)
.subscribeAndAwait
(Map<String, Integer> topics) Blocking variant ofsubscribe(Map)
.subscribeAndForget
(String topic, int qos) Variant ofsubscribe(String,int)
that ignores the result of the operation.subscribeAndForget
(Map<String, Integer> topics) Variant ofsubscribe(Map)
that ignores the result of the operation.subscribeCompletionHandler
(Consumer<MqttSubAckMessage> subscribeCompletionHandler) toString()
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 topicsunsubscribeAndAwait
(String topic) Blocking variant ofunsubscribe(String)
.unsubscribeAndAwait
(List<String> topics) Blocking variant ofunsubscribe(List)
.unsubscribeAndForget
(String topic) Variant ofunsubscribe(String)
that ignores the result of the operation.unsubscribeAndForget
(List<String> topics) Variant ofunsubscribe(List)
that ignores the result of the operation.unsubscribeCompletionHandler
(Consumer<Integer> unsubscribeCompletionHandler)
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
MqttClient
public MqttClient(io.vertx.mqtt.MqttClient delegate) -
MqttClient
-
-
Method Details
-
getDelegate
public io.vertx.mqtt.MqttClient getDelegate()- Specified by:
getDelegate
in interfaceMutinyDelegate
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
create
- Parameters:
vertx
- Vert.x instanceoptions
- MQTT client options- Returns:
- MQTT client instance
-
create
- Parameters:
vertx
- Vert.x instance- Returns:
- MQTT client instance
-
connect
Connects to an MQTT server calling connectHandler after connectionUnlike the bare Vert.x variant, this method returns a
Uni
. 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:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
Blocking variant ofconnect(int,String)
.This method waits 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 a RuntimeException).
- Parameters:
port
- port of the MQTT serverhost
- hostname/ip address of the MQTT server- Returns:
- the MqttConnAckMessage instance produced by the operation.
-
connectAndForget
Variant ofconnect(int,String)
that ignores the result of the operation.This method subscribes on the result of
connect(int,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(int,String)
but you don't need to compose it with other operations.- Parameters:
port
- port of the MQTT serverhost
- hostname/ip address of the MQTT server- Returns:
- the instance of MqttClient to chain method calls.
-
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
. 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:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
connectAndAwait
Blocking variant ofconnect(int,String,String)
.This method waits 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 a RuntimeException).
- Parameters:
port
- port of the MQTT serverhost
- hostname/ip address of the MQTT serverserverName
- the SNI server name- Returns:
- the MqttConnAckMessage instance produced by the operation.
-
connectAndForget
Variant ofconnect(int,String,String)
that ignores the result of the operation.This method subscribes on the result of
connect(int,String,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromconnect(int,String,String)
but you don't need to compose it with other operations.- Parameters:
port
- port of the MQTT serverhost
- hostname/ip address of the MQTT serverserverName
- the SNI server name- Returns:
- the instance of MqttClient to chain method calls.
-
disconnect
Disconnects from the MQTT server calling disconnectHandler after disconnectionUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
disconnectAndAwait
Blocking variant ofdisconnect()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
disconnectAndForget
Variant ofdisconnect()
that ignores the result of the operation.This method subscribes on the result of
disconnect()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromdisconnect()
but you don't need to compose it with other operations.- Returns:
- the instance of MqttClient to chain method calls.
-
publish
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> publish(String topic, 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
. 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:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
publishAndAwait
public Integer publishAndAwait(String topic, Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Blocking variant ofpublish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
.This method waits 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 a RuntimeException).
- 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 Integer instance produced by the operation.
-
publishAndForget
public MqttClient publishAndForget(String topic, Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain) Variant ofpublish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
that ignores the result of the operation.This method subscribes on the result of
publish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompublish(String,io.vertx.mutiny.core.buffer.Buffer,MqttQoS,boolean,boolean)
but you don't need to compose it with other operations.- 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 instance of MqttClient to chain method calls.
-
publishCompletionHandler
- Parameters:
publishCompletionHandler
- handler called with the packetId- Returns:
-
publishCompletionExpirationHandler
public MqttClient publishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler) - Parameters:
publishCompletionExpirationHandler
- the handler to call with the ID of the expired packet- Returns:
-
publishCompletionUnknownPacketIdHandler
public MqttClient publishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler) - Parameters:
publishCompletionPhantomHandler
- the handler to call with the unknown packet ID- Returns:
-
publishHandler
- Parameters:
publishHandler
- handler to call- Returns:
-
subscribeCompletionHandler
public MqttClient subscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler) - Parameters:
subscribeCompletionHandler
- handler to call. List inside is a granted QoS array- Returns:
-
subscribe
Subscribes to the topic with a specified QoS levelUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
topic
- topic you subscribe onqos
- QoS level- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
subscribeAndAwait
Blocking variant ofsubscribe(String,int)
.This method waits 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 a RuntimeException).
- Parameters:
topic
- topic you subscribe onqos
- QoS level- Returns:
- the Integer instance produced by the operation.
-
subscribeAndForget
Variant ofsubscribe(String,int)
that ignores the result of the operation.This method subscribes on the result of
subscribe(String,int)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsubscribe(String,int)
but you don't need to compose it with other operations.- Parameters:
topic
- topic you subscribe onqos
- QoS level- Returns:
- the instance of MqttClient to chain method calls.
-
subscribe
Subscribes to the topic and adds a handler which will be called after the request is sentUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
topics
- topics you subscribe on- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
subscribeAndAwait
Blocking variant ofsubscribe(Map)
.This method waits 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 a RuntimeException).
- Parameters:
topics
- topics you subscribe on- Returns:
- the Integer instance produced by the operation.
-
subscribeAndForget
Variant ofsubscribe(Map)
that ignores the result of the operation.This method subscribes on the result of
subscribe(Map)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsubscribe(Map)
but you don't need to compose it with other operations.- Parameters:
topics
- topics you subscribe on- Returns:
- the instance of MqttClient to chain method calls.
-
unsubscribeCompletionHandler
- Parameters:
unsubscribeCompletionHandler
- handler to call with the packetid- Returns:
-
unsubscribe
Unsubscribe from receiving messages on given topicsUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
topics
- list of topics you want to unsubscribe from- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
unsubscribeAndAwait
Blocking variant ofunsubscribe(List)
.This method waits 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 a RuntimeException).
- Parameters:
topics
- list of topics you want to unsubscribe from- Returns:
- the Integer instance produced by the operation.
-
unsubscribeAndForget
Variant ofunsubscribe(List)
that ignores the result of the operation.This method subscribes on the result of
unsubscribe(List)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromunsubscribe(List)
but you don't need to compose it with other operations.- Parameters:
topics
- list of topics you want to unsubscribe from- Returns:
- the instance of MqttClient to chain method calls.
-
unsubscribe
Unsubscribe from receiving messages on given topicUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
topic
- list of topics you want to unsubscribe from- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
unsubscribeAndAwait
Blocking variant ofunsubscribe(String)
.This method waits 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 a RuntimeException).
- Parameters:
topic
- list of topics you want to unsubscribe from- Returns:
- the Integer instance produced by the operation.
-
unsubscribeAndForget
Variant ofunsubscribe(String)
that ignores the result of the operation.This method subscribes on the result of
unsubscribe(String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromunsubscribe(String)
but you don't need to compose it with other operations.- Parameters:
topic
- list of topics you want to unsubscribe from- Returns:
- the instance of MqttClient to chain method calls.
-
pingResponseHandler
- Parameters:
pingResponseHandler
- handler to call- Returns:
-
exceptionHandler
- Parameters:
handler
- the exception handler- Returns:
-
closeHandler
- Parameters:
closeHandler
- handler to call- Returns:
-
ping
- Returns:
- current MQTT client instance
-
clientId
- Returns:
- the client identifier
-
isConnected
public boolean isConnected()- Returns:
- if the connection between client and remote server is established/open
-
newInstance
-