Class AbstractVertxBasedMqttProtocolAdapter.MqttDeviceEndpoint

    • Constructor Summary

      Constructors 
      Constructor Description
      MqttDeviceEndpoint​(io.vertx.mqtt.MqttEndpoint endpoint, org.eclipse.hono.auth.Device authenticatedDevice, OptionalInt traceSamplingPriority)
      Creates a new MqttDeviceEndpoint.
    • 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 or null if 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 is null.
    • 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 is null.
      • 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 be null).
        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 is null.
      • 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 is null.
      • 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 is null.
      • 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 is null.
      • 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 are null.
      • 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 is null.
      • onClose

        protected final void onClose()
        Closes a connection to a client.