Class AbstractMqttMessageHandler<T extends com.hivemq.client.mqtt.MqttClient>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.mqtt.client.outbound.AbstractMqttMessageHandler<T>
- Type Parameters:
T- MQTT Client type
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationEventPublisherAware, Ordered, ComponentSourceAware, ExpressionCapable, Orderable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
Mqtt3MessageHandler, Mqtt5MessageHandler
public abstract class AbstractMqttMessageHandler<T extends com.hivemq.client.mqtt.MqttClient>
extends AbstractMessageHandler
implements ApplicationEventPublisherAware
Abstract class for MQTT Outbound Adapters.
- Since:
- 7.2
- Author:
- Jiandong Ma, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMqttMessageHandler(ClientManager<T> mqttClientManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ObjectbuildMqttMessage(String topic, byte[] body, com.hivemq.client.mqtt.datatypes.MqttQos qos, boolean retained, Message<?> message) protected Tprotected StandardEvaluationContextprotected voidhandleMessageInternal(Message<?> message) protected booleanisAsync()protected abstract booleanisMqttMessage(Object payload) protected voidmessageSentEvent(Message<?> message, Object mqttPublish) protected voidonInit()Subclasses may implement this for initialization logic.protected abstract voidpublishMqttMessage(Object messageForPublish, Message<?> message) protected voidsendDeliveryCompleteEvent(Object mqttPublishResult) protected voidsendFailedDeliveryEvent(Object mqttPublishResult, Throwable ex) voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetAsync(boolean async) Set to true if you don't want to block when sending messages.voidsetDefaultQos(com.hivemq.client.mqtt.datatypes.MqttQos defaultQos) Set the qos for messages if theqosExpressionevaluates to null.voidsetDefaultRetained(boolean defaultRetained) Set the retained boolean for messages if theretainedExpressionevaluates to null.voidsetDefaultTopic(String defaultTopic) Set the topic to which the message will be published if thetopicExpressionevaluates to `null`.voidsetMessageConverter(MessageConverter messageConverter) Set the message converter to use.voidsetQosExpression(Expression qosExpression) Set the qos expression; defaultheaders['mqtt_qos'].voidsetQosExpressionString(String qosExpression) Set the qos expression; defaultheaders['mqtt_qos'].voidsetRetainedExpression(Expression retainedExpression) Set the retained expression; defaultheaders['mqtt_retained'].voidsetRetainedExpressionString(String retainedExpression) Set the retained expression; defaultheaders['mqtt_retained'].voidsetTopicExpression(Expression topicExpression) Set the topic expression; defaultheaders['mqtt_topic'].voidsetTopicExpressionString(String topicExpression) Set the topic expression; defaultheaders['mqtt_topic'].Methods inherited from class AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class MessageHandlerSupport
buildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface IntegrationManagement
getThisAsMethods inherited from interface NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
AbstractMqttMessageHandler
-
-
Method Details
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
setMessageConverter
Set the message converter to use.- Parameters:
messageConverter- the messageConverter.
-
setAsync
public void setAsync(boolean async) Set to true if you don't want to block when sending messages. Default false. When true, message sent/delivered events will be published for reception by a suitably configured 'ApplicationListener' or an event inbound-channel-adapter.- Parameters:
async- true for async.
-
setDefaultTopic
Set the topic to which the message will be published if thetopicExpressionevaluates to `null`.- Parameters:
defaultTopic- the default topic.
-
setTopicExpression
Set the topic expression; defaultheaders['mqtt_topic'].- Parameters:
topicExpression- the expression.
-
setTopicExpressionString
Set the topic expression; defaultheaders['mqtt_topic'].- Parameters:
topicExpression- the expression.
-
setDefaultQos
public void setDefaultQos(com.hivemq.client.mqtt.datatypes.MqttQos defaultQos) Set the qos for messages if theqosExpressionevaluates to null.- Parameters:
defaultQos- the default qos.
-
setQosExpression
Set the qos expression; defaultheaders['mqtt_qos'].- Parameters:
qosExpression- the expression.
-
setQosExpressionString
Set the qos expression; defaultheaders['mqtt_qos'].- Parameters:
qosExpression- the expression.
-
setDefaultRetained
public void setDefaultRetained(boolean defaultRetained) Set the retained boolean for messages if theretainedExpressionevaluates to null.- Parameters:
defaultRetained- the defaultRetained.
-
setRetainedExpression
Set the retained expression; defaultheaders['mqtt_retained'].- Parameters:
retainedExpression- the expression.
-
setRetainedExpressionString
Set the retained expression; defaultheaders['mqtt_retained'].- Parameters:
retainedExpression- the expression.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classIntegrationObjectSupport
-
getEvaluationContext
-
getClient
-
isAsync
protected boolean isAsync() -
handleMessageInternal
- Specified by:
handleMessageInternalin classAbstractMessageHandler
-
isMqttMessage
-
buildMqttMessage
-
publishMqttMessage
-
messageSentEvent
-
sendDeliveryCompleteEvent
-
sendFailedDeliveryEvent
-
getComponentType
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-