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 theoriginalnon 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 StringclientId()MqttClientcloseHandler(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 connectionMqttConnAckMessageconnectAndAwait(int port, String host)Blocking variant ofconnect(int,String).MqttConnAckMessageconnectAndAwait(int port, String host, String serverName)Blocking variant ofconnect(int,String,String).MqttClientconnectAndForget(int port, String host)Variant ofconnect(int,String)that ignores the result of the operation.MqttClientconnectAndForget(int port, String host, String serverName)Variant ofconnect(int,String,String)that ignores the result of the operation.static MqttClientcreate(Vertx vertx)static MqttClientcreate(Vertx vertx, io.vertx.mqtt.MqttClientOptions options)io.smallrye.mutiny.Uni<Void>disconnect()Disconnects from the MQTT server calling disconnectHandler after disconnectionVoiddisconnectAndAwait()Blocking variant ofdisconnect().MqttClientdisconnectAndForget()Variant ofdisconnect()that ignores the result of the operation.booleanequals(Object o)MqttClientexceptionHandler(Consumer<Throwable> handler)io.vertx.mqtt.MqttClientgetDelegate()inthashCode()booleanisConnected()static MqttClientnewInstance(io.vertx.mqtt.MqttClient arg)MqttClientping()MqttClientpingResponseHandler(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 serverIntegerpublishAndAwait(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).MqttClientpublishAndForget(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.MqttClientpublishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler)MqttClientpublishCompletionHandler(Consumer<Integer> publishCompletionHandler)MqttClientpublishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler)MqttClientpublishHandler(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 sentIntegersubscribeAndAwait(String topic, int qos)Blocking variant ofsubscribe(String,int).IntegersubscribeAndAwait(Map<String,Integer> topics)Blocking variant ofio.vertx.mutiny.mqtt.MqttClient#subscribe(Map.) MqttClientsubscribeAndForget(String topic, int qos)Variant ofsubscribe(String,int)that ignores the result of the operation.MqttClientsubscribeAndForget(Map<String,Integer> topics)Variant ofio.vertx.mutiny.mqtt.MqttClient#subscribe(Mapthat ignores the result of the operation.) MqttClientsubscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler)StringtoString()io.smallrye.mutiny.Uni<Integer>unsubscribe(String topic)Unsubscribe from receiving messages on given topicIntegerunsubscribeAndAwait(String topic)Blocking variant ofunsubscribe(String).MqttClientunsubscribeAndForget(String topic)Variant ofunsubscribe(String)that ignores the result of the operation.MqttClientunsubscribeCompletionHandler(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
unifiring 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
unifiring 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
unifiring 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
unifiring 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
unifiring 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
unifiring the result of the operation when completed, or a failure if the operation failed.
-
subscribeAndAwait
public Integer subscribeAndAwait(Map<String,Integer> topics)
Blocking variant ofio.vertx.mutiny.mqtt.MqttClient#subscribe(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 ofio.vertx.mutiny.mqtt.MqttClient#subscribe(Mapthat ignores the result of the operation.) This method subscribes on the result of
io.vertx.mutiny.mqtt.MqttClient#subscribe(Map, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from) io.vertx.mutiny.mqtt.MqttClient#subscribe(Mapbut 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(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- Topic you want to unsubscribe from- Returns:
- the
unifiring 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- Topic 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- Topic 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)
-
-