Class AbstractMqttMessageHandler<T,C> 
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler<T,C> 
- Type Parameters:
- T- MQTT Client type
- C- MQTT connection options type (v5 or v3)
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- Ordered,- ExpressionCapable,- Orderable,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
- MqttPahoMessageHandler,- Mqttv5PahoMessageHandler
public abstract class AbstractMqttMessageHandler<T,C> 
extends AbstractMessageHandler
implements ManageableLifecycle, ApplicationEventPublisherAware
Abstract class for MQTT outbound channel adapters.
- Since:
- 4.0
- Author:
- Gary Russell, Artem Bilan, Artem Vozhdayenko
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longThe default completion timeout in milliseconds.static final longThe default disconnect completion timeout in milliseconds.protected final LockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractMqttMessageHandler(String url, String clientId) AbstractMqttMessageHandler(ClientManager<T, C> clientManager) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voiddoStart()protected abstract voiddoStop()protected ApplicationEventPublisherintIncremented each time the client is connected.protected ClientManager<T,C> protected longSubclasses may implement this method to provide component type information.protected MessageConverterprotected intprotected booleanprotected Stringprotected longprotected MessageProcessor<Integer>protected MessageProcessor<Boolean>protected MessageProcessor<String>protected StringgetUrl()protected voidhandleMessageInternal(Message<?> message) protected voidbooleanprotected voidonInit()Subclasses may implement this for initialization logic.protected abstract voidvoidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetCompletionTimeout(long completionTimeout) Set the completion timeout for async operations.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`.voidsetDisconnectCompletionTimeout(long completionTimeout) Set the completion timeout when disconnecting.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']".final voidstart()final voidstop()Methods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
DISCONNECT_COMPLETION_TIMEOUTpublic static final long DISCONNECT_COMPLETION_TIMEOUTThe default disconnect completion timeout in milliseconds.- See Also:
 
- 
DEFAULT_COMPLETION_TIMEOUTpublic static final long DEFAULT_COMPLETION_TIMEOUTThe default completion timeout in milliseconds.- See Also:
 
- 
lock
 
- 
- 
Constructor Details- 
AbstractMqttMessageHandler
- 
AbstractMqttMessageHandler
 
- 
- 
Method Details- 
setApplicationEventPublisher- Specified by:
- setApplicationEventPublisherin interface- ApplicationEventPublisherAware
 
- 
getApplicationEventPublisher
- 
setDefaultTopicSet the topic to which the message will be published if thetopicExpressionevaluates to `null`.- Parameters:
- defaultTopic- the default topic.
 
- 
getDefaultTopic
- 
setTopicExpressionSet the topic expression; default "headers['mqtt_topic']".- Parameters:
- topicExpression- the expression.
- Since:
- 5.0
 
- 
setTopicExpressionStringSet the topic expression; default "headers['mqtt_topic']".- Parameters:
- topicExpression- the expression.
- Since:
- 5.0
 
- 
getTopicProcessor
- 
setDefaultQospublic 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:
 
- 
getDefaultQosprotected int getDefaultQos()
- 
setQosExpressionSet 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:
 
- 
setQosExpressionStringSet 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:
 
- 
getQosProcessor
- 
setDefaultRetainedpublic 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:
 
- 
getDefaultRetainedprotected boolean getDefaultRetained()
- 
setRetainedExpressionSet 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:
 
- 
setRetainedExpressionStringSet 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:
 
- 
getRetainedProcessor
- 
setConverterSet the message converter to use; if this is provided, the adapter qos and retained settings are ignored.- Parameters:
- converter- the converter.
 
- 
getConverter
- 
getUrl
- 
getClientId
- 
getClientInstancepublic int getClientInstance()Incremented each time the client is connected.- Returns:
- The instance;
- Since:
- 4.1
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
incrementClientInstanceprotected void incrementClientInstance()
- 
setCompletionTimeoutpublic void setCompletionTimeout(long completionTimeout) Set the completion timeout for async operations. Not settable using the namespace. Default 30000L milliseconds.- Parameters:
- completionTimeout- The timeout.
- Since:
- 4.1
 
- 
getCompletionTimeoutprotected long getCompletionTimeout()
- 
setDisconnectCompletionTimeoutpublic void setDisconnectCompletionTimeout(long completionTimeout) Set the completion timeout when disconnecting. Not settable using the namespace. Default 5000L milliseconds.- Parameters:
- completionTimeout- The timeout.
- Since:
- 5.1.10
 
- 
getDisconnectCompletionTimeoutprotected long getDisconnectCompletionTimeout()
- 
getClientManager
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
startpublic final void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
 
- 
doStartprotected abstract void doStart()
- 
stoppublic final void stop()- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
 
- 
doStopprotected abstract void doStop()
- 
isRunningpublic boolean isRunning()- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
 
- 
handleMessageInternal- Specified by:
- handleMessageInternalin class- AbstractMessageHandler
 
- 
publish
 
-