Class AbstractVertxBasedMqttProtocolAdapter.MqttDeviceEndpoint
- java.lang.Object
-
- org.eclipse.hono.adapter.mqtt.AbstractVertxBasedMqttProtocolAdapter.MqttDeviceEndpoint
-
- Enclosing class:
- AbstractVertxBasedMqttProtocolAdapter<T extends MqttProtocolAdapterProperties>
public class AbstractVertxBasedMqttProtocolAdapter.MqttDeviceEndpoint extends Object
The endpoint representing a connected MQTT device.
-
-
Constructor Summary
Constructors Constructor Description MqttDeviceEndpoint(io.vertx.mqtt.MqttEndpoint endpoint, org.eclipse.hono.auth.Device authenticatedDevice, OptionalInt traceSamplingPriority)Creates a new MqttDeviceEndpoint.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.vertx.core.Future<Void>applyTraceSamplingPriorityForTopicTenant(org.eclipse.hono.util.ResourceIdentifier topic, io.opentracing.Span span)Applies the trace sampling priority configured for the tenant derived from the given topic on the given span.voidhandlePubAck(Integer msgId)Invoked when a device sends an MQTT PUBACK packet.protected voidhandlePublishedMessage(io.vertx.mqtt.messages.MqttPublishMessage message)Invoked when a device sends an MQTT PUBLISH packet.protected voidonClose()Closes a connection to a client.protected voidonCommandReceived(org.eclipse.hono.util.TenantObject tenantObject, CommandSubscription subscription, org.eclipse.hono.client.command.CommandContext commandContext)Called for a command to be delivered to a device.protected voidonSubscribe(io.vertx.mqtt.messages.MqttSubscribeMessage subscribeMsg)Invoked when a device sends an MQTT SUBSCRIBE packet.protected voidonUnsubscribe(io.vertx.mqtt.messages.MqttUnsubscribeMessage unsubscribeMsg)Invoked when a device sends an MQTT UNSUBSCRIBE packet.protected io.vertx.core.Future<Void>publishError(ErrorSubscription subscription, MqttContext context, Throwable error, io.opentracing.SpanContext spanContext)Publishes an error message to the device.protected voidregisterHandlers()Registers the handlers on the contained MqttEndpoint.
-
-
-
Constructor Detail
-
MqttDeviceEndpoint
public MqttDeviceEndpoint(io.vertx.mqtt.MqttEndpoint endpoint, org.eclipse.hono.auth.Device authenticatedDevice, OptionalInt traceSamplingPriority)Creates a new MqttDeviceEndpoint.- Parameters:
endpoint- The endpoint representing the connection to the device.authenticatedDevice- The authenticated identity of the device ornullif the device has not been authenticated.traceSamplingPriority- The sampling priority to be applied on the OpenTracing spans created in the context of this endpoint.- Throws:
NullPointerException- if endpoint or traceSamplingPriority isnull.
-
-
Method Detail
-
registerHandlers
protected final void registerHandlers()
Registers the handlers on the contained MqttEndpoint.
-
handlePublishedMessage
protected final void handlePublishedMessage(io.vertx.mqtt.messages.MqttPublishMessage message)
Invoked when a device sends an MQTT PUBLISH packet.- Parameters:
message- The message received from the device.- Throws:
NullPointerException- if message isnull.
-
applyTraceSamplingPriorityForTopicTenant
protected final io.vertx.core.Future<Void> applyTraceSamplingPriorityForTopicTenant(org.eclipse.hono.util.ResourceIdentifier topic, io.opentracing.Span span)
Applies the trace sampling priority configured for the tenant derived from the given topic on the given span.This is for unauthenticated MQTT connections where the tenant id gets taken from the message topic.
- Parameters:
topic- The topic (may benull).span- The OpenTracing span to apply the configuration to.- Returns:
- A succeeded future indicating the outcome of the operation. A failure to determine the tenant is ignored here.
- Throws:
NullPointerException- if span isnull.
-
handlePubAck
public final void handlePubAck(Integer msgId)
Invoked when a device sends an MQTT PUBACK packet.- Parameters:
msgId- The message/packet id.- Throws:
NullPointerException- if msgId isnull.
-
onSubscribe
protected final void onSubscribe(io.vertx.mqtt.messages.MqttSubscribeMessage subscribeMsg)
Invoked when a device sends an MQTT SUBSCRIBE packet.This method supports topic filters for subscribing to commands and error messages as defined by Hono's MQTT adapter user guide.
When a device subscribes to a command topic filter, this method opens a command consumer for receiving commands from applications for the device and sends an empty notification downstream, indicating that the device will be ready to receive commands until further notice.
- Parameters:
subscribeMsg- The subscribe request received from the device.- Throws:
NullPointerException- if subscribeMsg isnull.
-
publishError
protected final io.vertx.core.Future<Void> publishError(ErrorSubscription subscription, MqttContext context, Throwable error, io.opentracing.SpanContext spanContext)
Publishes an error message to the device.Used for an error that occurred in the context of the given MqttContext, while processing an MQTT message published by a device.
- Parameters:
subscription- The device's command subscription.context- The context in which the error occurred.error- The error exception.spanContext- The span context.- Returns:
- A future indicating the outcome of the operation.
- Throws:
NullPointerException- if any of the parameters except spanContext isnull.
-
onCommandReceived
protected final void onCommandReceived(org.eclipse.hono.util.TenantObject tenantObject, CommandSubscription subscription, org.eclipse.hono.client.command.CommandContext commandContext)Called for a command to be delivered to a device.- Parameters:
tenantObject- The tenant configuration object.subscription- The device's command subscription.commandContext- The command to be delivered.- Throws:
NullPointerException- if any of the parameters arenull.
-
onUnsubscribe
protected final void onUnsubscribe(io.vertx.mqtt.messages.MqttUnsubscribeMessage unsubscribeMsg)
Invoked when a device sends an MQTT UNSUBSCRIBE packet.This method currently only supports topic filters for unsubscribing from commands as defined by Hono's MQTT adapter user guide.
- Parameters:
unsubscribeMsg- The unsubscribe request received from the device.- Throws:
NullPointerException- if unsubscribeMsg isnull.
-
onClose
protected final void onClose()
Closes a connection to a client.
-
-