Class VertxBasedMqttProtocolAdapter
- java.lang.Object
-
- io.vertx.core.AbstractVerticle
-
- org.eclipse.hono.util.ConfigurationSupportingVerticle<T>
-
- org.eclipse.hono.service.AbstractServiceBase<T>
-
- org.eclipse.hono.adapter.AbstractProtocolAdapterBase<T>
-
- org.eclipse.hono.adapter.mqtt.AbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>
-
- org.eclipse.hono.adapter.mqtt.impl.VertxBasedMqttProtocolAdapter
-
- All Implemented Interfaces:
io.vertx.core.Verticle,ProtocolAdapter,HealthCheckProvider
public final class VertxBasedMqttProtocolAdapter extends AbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>
A Vert.x based Hono protocol adapter for publishing messages to Hono's Telemetry and Event APIs using MQTT.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.hono.adapter.mqtt.AbstractVertxBasedMqttProtocolAdapter
AbstractVertxBasedMqttProtocolAdapter.MqttDeviceEndpoint
-
-
Field Summary
-
Fields inherited from class org.eclipse.hono.adapter.mqtt.AbstractVertxBasedMqttProtocolAdapter
MEMORY_PER_CONNECTION, MINIMAL_MEMORY_JVM, MINIMAL_MEMORY_SUBSTRATE
-
Fields inherited from class org.eclipse.hono.adapter.AbstractProtocolAdapterBase
CONTENT_TYPE_OCTET_STREAM, KEY_MICROMETER_SAMPLE
-
Fields inherited from class org.eclipse.hono.service.AbstractServiceBase
log, tracer
-
-
Constructor Summary
Constructors Constructor Description VertxBasedMqttProtocolAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcustomizeDownstreamMessageProperties(Map<String,Object> props, MqttContext ctx)Invoked before the message is sent to the downstream peer.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.StringgetTypeName()protected io.vertx.core.Future<Void>onPublishedMessage(MqttContext ctx)Processes an MQTT message that has been published by a device.voidsetMessageMapping(MessageMapping<MqttContext> messageMappingService)Sets a service to call out to for published MQTT messages.-
Methods inherited from class org.eclipse.hono.adapter.mqtt.AbstractVertxBasedMqttProtocolAdapter
createAuthHandler, doStart, doStop, getActualInsecurePort, getActualPort, getInsecurePortDefaultValue, getMetrics, getPortDefaultValue, handleBeforeCredentialsValidation, onClose, onMessageSent, onMessageUndeliverable, setAuthHandler, setMetrics, setMqttInsecureServer, setMqttSecureServer, uploadCommandResponseMessage, uploadEventMessage, uploadMessage, uploadTelemetryMessage
-
Methods inherited from class org.eclipse.hono.adapter.AbstractProtocolAdapterBase
addMicrometerSample, checkConnectionDurationLimit, checkConnectionLimit, checkDeviceRegistration, checkMessageLimit, getCommandConsumerFactory, getCommandResponseSender, getConnectionEventProducer, getConnectionLimitManager, getCredentialsClient, getDownstreamMessageProperties, getEventSender, getMicrometerSample, getOutcome, getRegistrationAssertion, getRegistrationClient, getResourceLimitChecks, getServerTrustOptions, getTelemetrySender, getTenantClient, getTenantConfiguration, isAdapterEnabled, isPayloadOfIndicatedType, isTerminalError, registerEventLoopBlockedCheck, registerLivenessChecks, registerReadinessChecks, sendCommandResponse, sendConnectedEvent, sendConnectedTtdEvent, sendDisconnectedEvent, sendDisconnectedTtdEvent, sendTtdEvent, setCommandConsumerFactory, setCommandRouterClient, setConfig, setConnectionEventProducer, setConnectionLimitManager, setCredentialsClient, setMessagingClientProviders, setRegistrationClient, setResourceLimitChecks, setTenantClient, startInternal, startServiceClient, stopInternal, stopServiceClient, updateLastGateway, updateLastGateway, validateAddress
-
Methods inherited from class org.eclipse.hono.service.AbstractServiceBase
addTlsKeyCertOptions, addTlsTrustOptions, checkPortConfiguration, determineInsecurePort, determineSecurePort, getBindAddress, getInsecurePort, getInsecurePortBindAddress, getPort, isInsecurePortEnabled, isSecurePortEnabled, setHealthCheckServer, setTracer, start, stop
-
Methods inherited from class org.eclipse.hono.util.ConfigurationSupportingVerticle
getConfig, setSpecificConfig
-
Methods inherited from class io.vertx.core.AbstractVerticle
config, deploymentID, getVertx, init, processArgs, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.hono.adapter.ProtocolAdapter
getTimeUntilDisconnect
-
-
-
-
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 isnull.
-
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
- Specified by:
onPublishedMessagein classAbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>- Parameters:
ctx- The context in which the MQTT message has been published. TheMqttContext.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.
-
customizeDownstreamMessageProperties
protected void customizeDownstreamMessageProperties(Map<String,Object> props, MqttContext ctx)
Description copied from class:AbstractVertxBasedMqttProtocolAdapterInvoked before the message is sent to the downstream peer.Subclasses may override this method in order to customize the properties used for sending the message, e.g. adding custom properties.
- Overrides:
customizeDownstreamMessagePropertiesin classAbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>- Parameters:
props- The properties that are being added to the downstream message.ctx- The message processing context.
-
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:
getCommandPayloadin classAbstractVertxBasedMqttProtocolAdapter<MqttProtocolAdapterProperties>- Parameters:
ctx- The command context for this command.- Returns:
- A future containing the mapped buffer.
-
-