Class VertxBasedMqttProtocolAdapter

    • Constructor Detail

      • VertxBasedMqttProtocolAdapter

        public VertxBasedMqttProtocolAdapter()
    • Method Detail

      • getTypeName

        public String getTypeName()
        Returns:
        Constants.PROTOCOL_ADAPTER_TYPE_MQTT
      • setMessageMapping

        public void setMessageMapping​(MessageMapping<MqttContext> messageMappingService)
        Sets a service to call out to for published MQTT messages.

        The service will be invoked after the client device has been authenticated and before the downstream AMQP message is being created.

        Parameters:
        messageMappingService - The service to use for messageMapping messages.
        Throws:
        NullPointerException - if messageMapping is null.
      • onPublishedMessage

        protected io.vertx.core.Future<Void> onPublishedMessage​(MqttContext ctx)
        Processes an MQTT message that has been published by a device.

        Subclasses should determine

        • the tenant and identifier of the device that has published the message
        • the payload to send downstream
        • the content type of the payload
        and then invoke one of the upload* methods to send the message downstream.
        Specified by:
        onPublishedMessage in class AbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>
        Parameters:
        ctx - The context in which the MQTT message has been published. The MqttContext.topic() method will return a non-null resource identifier for the topic that the message has been published to.
        Returns:
        A future indicating the outcome of the operation.

        The future will succeed if the message has been successfully uploaded. Otherwise, the future will fail with a ServiceInvocationException.

      • getCommandPayload

        protected io.vertx.core.Future<io.vertx.core.buffer.Buffer> getCommandPayload​(org.eclipse.hono.client.command.CommandContext ctx)
        Get the buffer to send as a command to the gateway/device.

        Subclasses should override this method in order to overwrite the provided command.

        Overrides:
        getCommandPayload in class AbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>
        Parameters:
        ctx - The command context for this command.
        Returns:
        A future containing the mapped buffer.