Interface Mqtt3AsyncClient
- All Superinterfaces:
Mqtt3Client,MqttClient
Mqtt3Client based on futures and callbacks.- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilder for aMqtt3Subscribeand additional arguments that are applied to asubscribe(Mqtt3Subscribe),subscribe(Mqtt3Subscribe, Consumer, boolean)orsubscribe(Mqtt3Subscribe, Consumer, Executor, boolean)call. -
Field Summary
Fields inherited from interface com.hivemq.client.mqtt.MqttClient
DEFAULT_SERVER_HOST, DEFAULT_SERVER_PORT, DEFAULT_SERVER_PORT_SSL, DEFAULT_SERVER_PORT_WEBSOCKET, DEFAULT_SERVER_PORT_WEBSOCKET_SSL -
Method Summary
Modifier and TypeMethodDescriptionconnect()Connects this client with the default Connect message.connect(@NotNull Mqtt3Connect connect) Connects this client with the given Connect message.Fluent counterpart ofconnect(Mqtt3Connect).Disconnects this client.publish(@NotNull Mqtt3Publish publish) Publishes the given Publish message.voidpublishes(@NotNull MqttGlobalPublishFilter filter, @NotNull Consumer<@NotNull Mqtt3Publish> callback) Globally consumes all incoming Publish messages matching the given filter.voidpublishes(@NotNull MqttGlobalPublishFilter filter, @NotNull Consumer<@NotNull Mqtt3Publish> callback, boolean manualAcknowledgement) Globally consumes all incoming Publish messages matching the given filter.voidpublishes(@NotNull MqttGlobalPublishFilter filter, @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull Executor executor) Globally consumes all incoming Publish messages matching the given filter.voidpublishes(@NotNull MqttGlobalPublishFilter filter, @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull Executor executor, boolean manualAcknowledgement) Globally consumes all incoming Publish messages matching the given filter.Fluent counterpart ofpublish(Mqtt3Publish).subscribe(@NotNull Mqtt3Subscribe subscribe) Subscribes this client with the given Subscribe message.subscribe(@NotNull Mqtt3Subscribe subscribe, @NotNull Consumer<@NotNull Mqtt3Publish> callback) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.subscribe(@NotNull Mqtt3Subscribe subscribe, @NotNull Consumer<@NotNull Mqtt3Publish> callback, boolean manualAcknowledgement) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.subscribe(@NotNull Mqtt3Subscribe subscribe, @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull Executor executor) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.subscribe(@NotNull Mqtt3Subscribe subscribe, @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull Executor executor, boolean manualAcknowledgement) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.default @NotNull Mqtt3AsyncClienttoAsync()Turns the API of this client into a asynchronous API based on futures and callbacks.unsubscribe(@NotNull Mqtt3Unsubscribe unsubscribe) Unsubscribes this client with the given Unsubscribe message.Fluent counterpart ofunsubscribe(Mqtt3Unsubscribe).Methods inherited from interface com.hivemq.client.mqtt.mqtt3.Mqtt3Client
getConfig, toBlocking, toRxMethods inherited from interface com.hivemq.client.mqtt.MqttClient
getState
-
Method Details
-
connect
Connects this client with the default Connect message.- Returns:
- see
connect(Mqtt3Connect). - See Also:
-
connect
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3ConnAck> connect(@NotNull @NotNull Mqtt3Connect connect) Connects this client with the given Connect message.- Parameters:
connect- the Connect message sent to the broker.- Returns:
- a
CompletableFuturewhich- completes normally with the ConnAck message if it does not contain an Error Code (connected successfully),
- completes exceptionally with a
Mqtt3ConnAckExceptionwrapping the ConnAck message if it contains an Error Code or - completes exceptionally with a different exception if an error occurred before the Connect message was sent or before the ConnAck message was received.
-
connectWith
Fluent counterpart ofconnect(Mqtt3Connect).Calling
Mqtt3ConnectBuilder.Send.send()on the returned builder has the same effect as callingconnect(Mqtt3Connect)with the result ofMqtt3ConnectBuilder.build().- Returns:
- the fluent builder for the Connect message.
- See Also:
-
subscribe
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3SubAck> subscribe(@NotNull @NotNull Mqtt3Subscribe subscribe) Subscribes this client with the given Subscribe message.See
publishes(MqttGlobalPublishFilter, Consumer)orpublishes(MqttGlobalPublishFilter, Consumer, Executor)to consume the incoming Publish messages. Alternatively, callsubscribe(Mqtt3Subscribe, Consumer)orsubscribe(Mqtt3Subscribe, Consumer, Executor)to consume the incoming Publish messages matching the subscriptions of the Subscribe message directly.- Parameters:
subscribe- the Subscribe messages sent to the broker.- Returns:
- a
CompletableFuturewhich- completes normally with the SubAck message if all subscriptions of the Subscribe message were successful (the SubAck message contains no Error Codes),
- completes exceptionally with a
Mqtt3SubAckExceptionwrapping the SubAck message if it contains at least one Error Code or - completes exceptionally with a different exception if an error occurred before the Subscribe message was sent or before a SubAck message was received.
-
subscribe
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3SubAck> subscribe(@NotNull @NotNull Mqtt3Subscribe subscribe, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.- Parameters:
subscribe- the Subscribe messages sent to the broker.callback- the callback for consuming the incoming Publish messages matching the subscriptions of the Subscribe message.- Returns:
- see
subscribe(Mqtt3Subscribe). - See Also:
-
subscribe
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3SubAck> subscribe(@NotNull @NotNull Mqtt3Subscribe subscribe, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull @NotNull Executor executor) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.The future is completed and the callback is executed on the given executor.
- Parameters:
subscribe- the Subscribe messages sent to the broker.callback- the callback for consuming the incoming Publish messages matching the subscriptions of the Subscribe message.executor- the executor where the future is completed and the callback is executed on.- Returns:
- see
subscribe(Mqtt3Subscribe). - See Also:
-
subscribe
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3SubAck> subscribe(@NotNull @NotNull Mqtt3Subscribe subscribe, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, boolean manualAcknowledgement) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.- Parameters:
subscribe- the Subscribe messages sent to the broker.callback- the callback for consuming the incoming Publish messages matching the subscriptions of the Subscribe message.manualAcknowledgement- whether the Publish messages are acknowledged manually.- Returns:
- see
subscribe(Mqtt3Subscribe). - Since:
- 1.2
- See Also:
-
subscribe
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3SubAck> subscribe(@NotNull @NotNull Mqtt3Subscribe subscribe, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull @NotNull Executor executor, boolean manualAcknowledgement) Subscribes this client with the given Subscribe message and consumes the incoming Publish messages matching the subscriptions of the Subscribe message with a callback.The future is completed and the callback is executed on the given executor.
- Parameters:
subscribe- the Subscribe messages sent to the broker.callback- the callback for consuming the incoming Publish messages matching the subscriptions of the Subscribe message.executor- the executor where the future is completed and the callback is executed on.manualAcknowledgement- whether the Publish messages are acknowledged manually.- Returns:
- see
subscribe(Mqtt3Subscribe). - Since:
- 1.2
- See Also:
-
subscribeWith
Fluent counterpart ofsubscribe(Mqtt3Subscribe),subscribe(Mqtt3Subscribe, Consumer, boolean)andsubscribe(Mqtt3Subscribe, Consumer, Executor, boolean).Calling
Mqtt3AsyncClient.Mqtt3SubscribeAndCallbackBuilder.Call.send()on the returned builder has the same effect as calling one of the following methods:subscribe(Mqtt3Subscribe)if no callback has been supplied to the buildersubscribe(Mqtt3Subscribe, Consumer)if only a callback has been supplied to the buildersubscribe(Mqtt3Subscribe, Consumer, Executor)if a callback and an executor have been supplied to the builder
- Returns:
- the fluent builder for the Subscribe message.
- See Also:
-
publishes
void publishes(@NotNull @NotNull MqttGlobalPublishFilter filter, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback) Globally consumes all incoming Publish messages matching the given filter.- Parameters:
filter- the filter with which all incoming Publish messages are filtered.callback- the callback for all incoming Publish messages matching the given filter.- See Also:
-
publishes
void publishes(@NotNull @NotNull MqttGlobalPublishFilter filter, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull @NotNull Executor executor) Globally consumes all incoming Publish messages matching the given filter.- Parameters:
filter- the filter with which all incoming Publish messages are filtered.callback- the callback for all incoming Publish messages matching the given filter.executor- the executor where the callback is executed on.- See Also:
-
publishes
void publishes(@NotNull @NotNull MqttGlobalPublishFilter filter, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, boolean manualAcknowledgement) Globally consumes all incoming Publish messages matching the given filter.- Parameters:
filter- the filter with which all incoming Publish messages are filtered.callback- the callback for all incoming Publish messages matching the given filter.manualAcknowledgement- whether the Publish messages are acknowledged manually.- Since:
- 1.2
- See Also:
-
publishes
void publishes(@NotNull @NotNull MqttGlobalPublishFilter filter, @NotNull @NotNull Consumer<@NotNull Mqtt3Publish> callback, @NotNull @NotNull Executor executor, boolean manualAcknowledgement) Globally consumes all incoming Publish messages matching the given filter.- Parameters:
filter- the filter with which all incoming Publish messages are filtered.callback- the callback for all incoming Publish messages matching the given filter.executor- the executor where the callback is executed on.manualAcknowledgement- whether the Publish messages are acknowledged manually.- Since:
- 1.2
- See Also:
-
unsubscribe
@NotNull @NotNull CompletableFuture<Void> unsubscribe(@NotNull @NotNull Mqtt3Unsubscribe unsubscribe) Unsubscribes this client with the given Unsubscribe message.- Parameters:
unsubscribe- the Unsubscribe message sent to the broker.- Returns:
- a
CompletableFuturewhich- completes normally when the corresponding UnsubAck message was received or
- completes exceptionally if an error occurred before the Unsubscribe message was sent or before a UnsubAck message was received.
-
unsubscribeWith
@CheckReturnValue @NotNull Mqtt3UnsubscribeBuilder.Send.Start<CompletableFuture<Void>> unsubscribeWith()Fluent counterpart ofunsubscribe(Mqtt3Unsubscribe).Calling
Mqtt3UnsubscribeBuilder.Send.Complete.send()on the returned builder has the same effect as callingunsubscribe(Mqtt3Unsubscribe)with the result ofMqtt3UnsubscribeBuilder.Complete.build().- Returns:
- the fluent builder for the Unsubscribe message.
- See Also:
-
publish
@NotNull @NotNull CompletableFuture<@NotNull Mqtt3Publish> publish(@NotNull @NotNull Mqtt3Publish publish) Publishes the given Publish message.- Parameters:
publish- the Publish message sent to the broker.- Returns:
- a
CompletableFuturewhich- completes normally with the same Publish message (for context) if the Publish message was successfully published or
- completes exceptionally if an error occurred before the Publish message was sent or before an acknowledgement message was received.
-
publishWith
Fluent counterpart ofpublish(Mqtt3Publish).Calling
Mqtt3PublishBuilder.Send.Complete.send()on the returned builder has the same effect as callingpublish(Mqtt3Publish)with the result ofMqtt3PublishBuilder.Complete.build().- Returns:
- the fluent builder for the Unsubscribe message.
- See Also:
-
disconnect
Disconnects this client.- Returns:
- the
CompletableFuturewhich- completes when the client was successfully disconnected or
- errors if not disconnected gracefully.
-
toAsync
Description copied from interface:Mqtt3ClientTurns the API of this client into a asynchronous API based on futures and callbacks.The asynchronous API can be used simultaneously with the other APIs.
- Specified by:
toAsyncin interfaceMqtt3Client- Returns:
- a asynchronous API for this client.
-