Class AbstractMqttMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>,Aware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,ApplicationContextAware,Lifecycle,Ordered,ExpressionCapable,Orderable,IntegrationPattern,NamedComponent,IntegrationManagement,ManageableLifecycle,TrackableComponent,MessageHandler,reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
MqttPahoMessageHandler
public abstract class AbstractMqttMessageHandler extends AbstractMessageHandler implements ManageableLifecycle
Abstract class for MQTT outbound channel adapters.
- Since:
- 4.0
- Author:
- Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors Constructor Description AbstractMqttMessageHandler(String url, String clientId) -
Method Summary
Modifier and Type Method Description protected abstract voiddoStart()protected abstract voiddoStop()StringgetClientId()intgetClientInstance()Incremented each time the client is connected.StringgetComponentType()Subclasses may implement this method to provide component type information.protected MessageConvertergetConverter()protected StringgetUrl()protected voidhandleMessageInternal(Message<?> message)protected voidincrementClientInstance()booleanisRunning()protected voidonInit()Subclasses may implement this for initialization logic.protected abstract voidpublish(String topic, Object mqttMessage, Message<?> message)voidsetConverter(MessageConverter converter)Set the message converter to use; if this is provided, the adapter qos and retained settings are ignored.voidsetDefaultQos(int 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`.voidsetQosExpression(Expression qosExpression)Set the qos expression; default "headers['mqtt_qos']".voidsetQosExpressionString(String qosExpression)Set the qos expression; default "headers['mqtt_qos']".voidsetRetainedExpression(Expression retainedExpression)Set the retained expression; default "headers['mqtt_retained']".voidsetRetainedExpressionString(String retainedExpression)Set the retained expression; default "headers['mqtt_retained']".voidsetTopicExpression(Expression topicExpression)Set the topic expression; default "headers['mqtt_topic']".voidsetTopicExpressionString(String topicExpression)Set the topic expression; default "headers['mqtt_topic']".voidstart()voidstop()Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribeMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
Method Details
-
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; default "headers['mqtt_topic']".- Parameters:
topicExpression- the expression.- Since:
- 5.0
-
setTopicExpressionString
Set the topic expression; default "headers['mqtt_topic']".- Parameters:
topicExpression- the expression.- Since:
- 5.0
-
setDefaultQos
public void setDefaultQos(int defaultQos)Set the qos for messages if theqosExpressionevaluates to null. Only applies if a message converter is not provided.- Parameters:
defaultQos- the default qos.- See Also:
setConverter(MessageConverter)
-
setQosExpression
Set the qos expression; default "headers['mqtt_qos']". Only applies if a message converter is not provided.- Parameters:
qosExpression- the expression.- Since:
- 5.0
- See Also:
setConverter(MessageConverter)
-
setQosExpressionString
Set the qos expression; default "headers['mqtt_qos']". Only applies if a message converter is not provided.- Parameters:
qosExpression- the expression.- Since:
- 5.0
- See Also:
setConverter(MessageConverter)
-
setDefaultRetained
public void setDefaultRetained(boolean defaultRetained)Set the retained boolean for messages if theretainedExpressionevaluates to null. Only applies if a message converter is not provided.- Parameters:
defaultRetained- the default defaultRetained.- See Also:
setConverter(MessageConverter)
-
setRetainedExpression
Set the retained expression; default "headers['mqtt_retained']". Only applies if a message converter is not provided.- Parameters:
retainedExpression- the expression.- Since:
- 5.0
- See Also:
setConverter(MessageConverter)
-
setRetainedExpressionString
Set the retained expression; default "headers['mqtt_retained']". Only applies if a message converter is not provided.- Parameters:
retainedExpression- the expression.- Since:
- 5.0
- See Also:
setConverter(MessageConverter)
-
setConverter
Set the message converter to use; if this is provided, the adapter qos and retained settings are ignored.- Parameters:
converter- the converter.
-
getConverter
-
getUrl
-
getClientId
-
getClientInstance
public int getClientInstance()Incremented each time the client is connected.- Returns:
- The instance;
- Since:
- 4.1
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
incrementClientInstance
protected void incrementClientInstance() -
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classIntegrationObjectSupport
-
start
public final void start()- Specified by:
startin interfaceLifecycle- Specified by:
startin interfaceManageableLifecycle
-
doStart
protected abstract void doStart() -
stop
public final void stop()- Specified by:
stopin interfaceLifecycle- Specified by:
stopin interfaceManageableLifecycle
-
doStop
protected abstract void doStop() -
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceLifecycle- Specified by:
isRunningin interfaceManageableLifecycle
-
handleMessageInternal
- Specified by:
handleMessageInternalin classAbstractMessageHandler
-
publish
-