Class AbstractMqttMessageDrivenChannelAdapter<T extends com.hivemq.client.mqtt.MqttClient>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.mqtt.client.inbound.AbstractMqttMessageDrivenChannelAdapter<T>
- Type Parameters:
T- MQTT Client type
- All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, SmartInitializingSingleton, ApplicationContextAware, ApplicationEventPublisherAware, Lifecycle, Phased, SmartLifecycle, ComponentSourceAware, ExpressionCapable, MessageProducer, IntegrationPattern, ClientManager.ConnectCallback, NamedComponent, IntegrationInboundManagement, IntegrationManagement, ManageableLifecycle, ManageableSmartLifecycle, TrackableComponent
- Direct Known Subclasses:
Mqtt3MessageDrivenChannelAdapter, Mqtt5MessageDrivenChannelAdapter
public abstract class AbstractMqttMessageDrivenChannelAdapter<T extends com.hivemq.client.mqtt.MqttClient>
extends MessageProducerSupport
implements ApplicationEventPublisherAware, ClientManager.ConnectCallback
Abstract class for MQTT Message-Driven Channel Adapters.
- Since:
- 7.2
- Author:
- Jiandong Ma
-
Nested Class Summary
Nested classes/interfaces inherited from interface IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanprotected final AtomicBooleanprotected SmartMessageConverterprotected final ClientManager<T> Fields inherited from class AbstractEndpoint
lifecycleLockFields inherited from class IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMqttMessageDrivenChannelAdapter(ClientManager<T> mqttClientManager) protectedAbstractMqttMessageDrivenChannelAdapter(ClientManager<T> mqttClientManager, String... topics) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()protected ApplicationEventPublisherprotected Tprotected @Nullable Executorprotected SmartMessageConverterprotected Class<?> protected com.hivemq.client.mqtt.datatypes.MqttQosgetQos()protected String @Nullable []booleanReturn whether the mqttClient isConnected.protected booleanprotected voidonInit()Subclasses may implement this for initialization logic.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetExecutor(Executor executor) Set the executor where the message callback is executed on.voidsetManualAck(boolean manualAck) Set whether the Publish messages are acknowledged manually.voidsetMessageConverter(SmartMessageConverter messageConverter) Set the messageConverter to convert the payload to the expected payloadType.voidsetPayloadType(Class<?> payloadType) Set the type of the target message payload to produce after conversion from MQTT message.voidsetQos(com.hivemq.client.mqtt.datatypes.MqttQos qos) Set the QoS for the topicMethods inherited from class MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, doStart, doStop, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, getOutputChannelName, getRequiredOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods 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 ClientManager.ConnectCallback
onClientConnectedMethods inherited from interface IntegrationManagement
getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface NamedComponent
getBeanName, getComponentNameMethods inherited from interface SmartLifecycle
isPauseable
-
Field Details
-
mqttClientManager
-
isSubscribing
-
isSubscribed
-
messageConverter
-
-
Constructor Details
-
AbstractMqttMessageDrivenChannelAdapter
-
AbstractMqttMessageDrivenChannelAdapter
protected AbstractMqttMessageDrivenChannelAdapter(ClientManager<T> mqttClientManager, String... topics)
-
-
Method Details
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
getApplicationEventPublisher
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessageProducerSupport
-
destroy
public void destroy()- Specified by:
destroyin interfaceDisposableBean- Specified by:
destroyin interfaceIntegrationManagement- Overrides:
destroyin classAbstractEndpoint
-
getClient
-
setMessageConverter
Set the messageConverter to convert the payload to the expected payloadType.- Parameters:
messageConverter- the messageConverter
-
getMessageConverter
-
getTopics
-
setQos
public void setQos(com.hivemq.client.mqtt.datatypes.MqttQos qos) Set the QoS for the topic- Parameters:
qos- The qos value
-
getQos
protected com.hivemq.client.mqtt.datatypes.MqttQos getQos() -
setManualAck
public void setManualAck(boolean manualAck) Set whether the Publish messages are acknowledged manually.- Parameters:
manualAck- true for manual ack.
-
isManualAck
protected boolean isManualAck() -
setExecutor
Set the executor where the message callback is executed on.- Parameters:
executor- the executor.
-
getExecutor
-
setPayloadType
Set the type of the target message payload to produce after conversion from MQTT message. Defaults tobyte[].class. Can be set toMqtt5Publishfor v5 orMqtt3Publishto produce the whole MQTT message as a payload.- Parameters:
payloadType- the expected payload type to convert MQTT message to.
-
getPayloadType
-
isConnected
public boolean isConnected()Return whether the mqttClient isConnected.- Returns:
- whether the mqttClient isConnected.
-
getComponentType
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageProducerSupport
-