Class MqttClient
- java.lang.Object
-
- io.vertx.mutiny.mqtt.MqttClient
-
public class MqttClient extends Object
An MQTT client NOTE: This class has been automatically generated from theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MqttClient>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description MqttClient(io.vertx.mqtt.MqttClient delegate)
MqttClient(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
clientId()
MqttClient
closeHandler(Runnable closeHandler)
io.smallrye.mutiny.Uni<MqttConnAckMessage>
connect(int port, String host)
Connects to an MQTT server calling connectHandler after connectionio.smallrye.mutiny.Uni<MqttConnAckMessage>
connect(int port, String host, String serverName)
Connects to an MQTT server calling connectHandler after connectionMqttConnAckMessage
connectAndAwait(int port, String host)
Blocking variant ofconnect(int,String)
.MqttConnAckMessage
connectAndAwait(int port, String host, String serverName)
Blocking variant ofconnect(int,String,String)
.MqttClient
connectAndForget(int port, String host)
Variant ofconnect(int,String)
that ignores the result of the operation.MqttClient
connectAndForget(int port, String host, String serverName)
Variant ofconnect(int,String,String)
that ignores the result of the operation.static MqttClient
create(Vertx vertx)
static MqttClient
create(Vertx vertx, io.vertx.mqtt.MqttClientOptions options)
io.smallrye.mutiny.Uni<Void>
disconnect()
Disconnects from the MQTT server calling disconnectHandler after disconnectionVoid
disconnectAndAwait()
Blocking variant ofdisconnect()
.MqttClient
disconnectAndForget()
Variant ofdisconnect()
that ignores the result of the operation.boolean
equals(Object o)
MqttClient
exceptionHandler(Consumer<Throwable> handler)
io.vertx.mqtt.MqttClient
getDelegate()
int
hashCode()
boolean
isConnected()
static MqttClient
newInstance(io.vertx.mqtt.MqttClient arg)
MqttClient
ping()
MqttClient
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 serverInteger
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)
.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.MqttClient
publishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler)
MqttClient
publishCompletionHandler(Consumer<Integer> publishCompletionHandler)
MqttClient
publishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler)
MqttClient
publishHandler(Consumer<MqttPublishMessage> publishHandler)
io.smallrye.mutiny.Uni<Integer>
subscribe(String topic, int qos)
Subscribes to the topic with a specified QoS levelio.smallrye.mutiny.Uni<Integer>
subscribe(Map<String,Integer> topics)
Subscribes to the topic and adds a handler which will be called after the request is sentInteger
subscribeAndAwait(String topic, int qos)
Blocking variant ofsubscribe(String,int)
.Integer
subscribeAndAwait(Map<String,Integer> topics)
Blocking variant ofsubscribe(Map)
.MqttClient
subscribeAndForget(String topic, int qos)
Variant ofsubscribe(String,int)
that ignores the result of the operation.MqttClient
subscribeAndForget(Map<String,Integer> topics)
Variant ofsubscribe(Map)
that ignores the result of the operation.MqttClient
subscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler)
String
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 topicsInteger
unsubscribeAndAwait(String topic)
Blocking variant ofunsubscribe(String)
.Integer
unsubscribeAndAwait(List<String> topics)
Blocking variant ofunsubscribe(List)
.MqttClient
unsubscribeAndForget(String topic)
Variant ofunsubscribe(String)
that ignores the result of the operation.MqttClient
unsubscribeAndForget(List<String> topics)
Variant ofunsubscribe(List)
that ignores the result of the operation.MqttClient
unsubscribeCompletionHandler(Consumer<Integer> unsubscribeCompletionHandler)
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<MqttClient> __TYPE_ARG
-
-
Constructor Detail
-
MqttClient
public MqttClient(io.vertx.mqtt.MqttClient delegate)
-
MqttClient
public MqttClient(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.mqtt.MqttClient getDelegate()
-
create
public static MqttClient create(Vertx vertx, io.vertx.mqtt.MqttClientOptions options)
- Parameters:
vertx
- Vert.x instanceoptions
- MQTT client options- Returns:
- MQTT client instance
-
create
public static MqttClient create(Vertx vertx)
- Parameters:
vertx
- Vert.x instance- Returns:
- MQTT client instance
-
connect
@CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host)
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
public MqttConnAckMessage connectAndAwait(int port, String host)
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
public MqttClient connectAndForget(int port, String host)
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
public MqttConnAckMessage connectAndAwait(int port, String host, String serverName)
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
public MqttClient connectAndForget(int port, String host, String serverName)
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> 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
public Void 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
public MqttClient 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
public MqttClient publishCompletionHandler(Consumer<Integer> 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
public MqttClient publishHandler(Consumer<MqttPublishMessage> 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
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> subscribe(String topic, int qos)
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
public Integer subscribeAndAwait(String topic, int qos)
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
public MqttClient subscribeAndForget(String topic, int qos)
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> subscribe(Map<String,Integer> topics)
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
public Integer subscribeAndAwait(Map<String,Integer> topics)
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
public MqttClient subscribeAndForget(Map<String,Integer> topics)
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
public MqttClient unsubscribeCompletionHandler(Consumer<Integer> unsubscribeCompletionHandler)
- Parameters:
unsubscribeCompletionHandler
- handler to call with the packetid- Returns:
-
unsubscribe
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> unsubscribe(List<String> topics)
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
public Integer unsubscribeAndAwait(List<String> topics)
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
public MqttClient unsubscribeAndForget(List<String> topics)
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
@CheckReturnValue public io.smallrye.mutiny.Uni<Integer> unsubscribe(String topic)
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
public Integer unsubscribeAndAwait(String topic)
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
public MqttClient unsubscribeAndForget(String topic)
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
public MqttClient pingResponseHandler(Runnable pingResponseHandler)
- Parameters:
pingResponseHandler
- handler to call- Returns:
-
exceptionHandler
public MqttClient exceptionHandler(Consumer<Throwable> handler)
- Parameters:
handler
- the exception handler- Returns:
-
closeHandler
public MqttClient closeHandler(Runnable closeHandler)
- Parameters:
closeHandler
- handler to call- Returns:
-
ping
public MqttClient ping()
- Returns:
- current MQTT client instance
-
clientId
public String clientId()
- Returns:
- the client identifier
-
isConnected
public boolean isConnected()
- Returns:
- if the connection between client and remote server is established/open
-
newInstance
public static MqttClient newInstance(io.vertx.mqtt.MqttClient arg)
-
-