Interface PublishService
-
@DoNotImplement public interface PublishService
This service allows extensions to publish new MQTT messages programmatically.- Since:
- 4.0.0, CE 2019.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull CompletableFuture<Void>
publish(@NotNull Publish publish)
Publishes a new MQTTPublish
message.@NotNull CompletableFuture<PublishToClientResult>
publishToClient(@NotNull Publish publish, @NotNull String clientId)
Publishes a new MQTTPublish
message to a single client.
-
-
-
Method Detail
-
publish
@NotNull CompletableFuture<Void> publish(@NotNull Publish publish)
Publishes a new MQTTPublish
message. The standard MQTT topic matching mechanism of HiveMQ will apply and only subscribed MQTT clients and consumers will receive the published message.CompletableFuture
fails with aRateLimitExceededException
if the extension service rate limit was exceeded.CompletableFuture
fails with aDoNotImplementException
if the Publish is implemented by the extension.- Parameters:
publish
- Object with topic, QoS and message, which should be published to all subscribed clients.- Returns:
- A
CompletableFuture
which is complete when the PublishPacket has been processed by HiveMQ. - Throws:
NullPointerException
- If the given publish isnull
.- Since:
- 4.0.0, CE 2019.1
-
publishToClient
@NotNull CompletableFuture<PublishToClientResult> publishToClient(@NotNull Publish publish, @NotNull String clientId)
Publishes a new MQTTPublish
message to a single client. The PUBLISH will only be delivered to the client with the specified client identifier. This method will not send the publish to the specified client if the client is not subscribed to a topic that matches the topic of the PUBLISH.If the client is subscribed to a shared subscription that matches the publish topic, the PUBLISH is still only delivered to the client with the specified client identifier. The retain flag is ignored for the PUBLISH message.
CompletableFuture
fails with aRateLimitExceededException
if the extension service rate limit was exceeded.CompletableFuture
fails with aDoNotImplementException
if the Publish is implemented by the extension.- Parameters:
publish
- Object with topic, QoS and message, which should be published to all subscribed clients.clientId
- The client to publish to.- Returns:
- A
CompletableFuture
which is complete when the PublishPacket has been processed by HiveMQ and contains aPublishToClientResult
that isPublishToClientResult.SUCCESSFUL
if the client has matching subscriptions orPublishToClientResult.NOT_SUBSCRIBED
if it doesn't. - Throws:
NullPointerException
- If the given publish or client id isnull
.IllegalArgumentException
- If the given client id is empty.- Since:
- 4.0.0, CE 2019.1
-
-