Class Mqttv5PahoMessageDrivenChannelAdapter
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
 
org.springframework.integration.mqtt.inbound.Mqttv5PahoMessageDrivenChannelAdapter
- All Implemented Interfaces:
- org.eclipse.paho.mqttv5.client.MqttCallback,- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- SmartInitializingSingleton,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- Phased,- SmartLifecycle,- ComponentSourceAware,- ExpressionCapable,- MessageProducer,- IntegrationPattern,- ClientManager.ConnectCallback,- MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
public class Mqttv5PahoMessageDrivenChannelAdapter
extends AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
implements org.eclipse.paho.mqttv5.client.MqttCallback, MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
The 
AbstractMqttMessageDrivenChannelAdapter implementation for MQTT v5.
 
 The MqttProperties are mapped via the provided HeaderMapper;
 meanwhile the regular MqttMessage properties are always mapped into headers.
 
 It is recommended to have the MqttConnectionOptions.setAutomaticReconnect(boolean)
 set to true to let an internal IMqttAsyncClient instance to handle reconnects.
 Otherwise, only the manual restart of this component can handle reconnects, e.g. via
 MqttConnectionFailedEvent handling on disconnection.
 
 See setPayloadType(java.lang.Class<?>) for more information about type conversion.
- Since:
- 5.5.5
- Author:
- Artem Bilan, Mikhail Polivakha, Lucas Bowler, Artem Vozhdayenko, Matthias Thoma
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdaptertopicLockFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields 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.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionMqttv5PahoMessageDrivenChannelAdapter(String url, String clientId, String... topic) Mqttv5PahoMessageDrivenChannelAdapter(String url, String clientId, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the MQTT url, client id and subscriptions.Mqttv5PahoMessageDrivenChannelAdapter(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId, String... topic) Mqttv5PahoMessageDrivenChannelAdapter(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the MQTT connection options, client id and subscriptions.Mqttv5PahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager, String... topic) Use this constructor when you need to use a singleClientManager(for instance, to reuse an MQTT connection).Mqttv5PahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the client manager and subscriptions.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd a topic to the subscribed list.voidauthPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) voidconnectComplete(boolean isReconnect) Called when the connection to the server is completed successfully.voidconnectComplete(boolean reconnect, String serverURI) voiddeliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) voiddestroy()voiddisconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.org.eclipse.paho.mqttv5.client.MqttConnectionOptionsReturn information about the connection.voidmessageArrived(String topic, org.eclipse.paho.mqttv5.common.MqttMessage mqttMessage) voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) protected voidonInit()Subclasses may implement this for initialization logic.voidremoveTopic(String... topic) Remove a topic (or topics) from the subscribed list.voidsetConverter(MqttMessageConverter converter) voidsetHeaderMapper(HeaderMapper<org.eclipse.paho.mqttv5.common.packet.MqttProperties> headerMapper) voidsetMessageConverter(SmartMessageConverter messageConverter) voidsetPayloadType(Class<?> payloadType) Set the type of the target message payload to produce after conversion from MQTT message.voidsetPersistence(org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence) voidsetQos(int... qos) Set the QoS for each topic; a single value will apply to all topics otherwise the correct number of qos values must be provided.Methods inherited from class org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdapteraddTopic, addTopics, getApplicationEventPublisher, getClientId, getClientManager, getCompletionTimeout, getComponentType, getConverter, getDisconnectCompletionTimeout, getQos, getTopic, getUrl, isManualAcks, setApplicationEventPublisher, setCompletionTimeout, setDisconnectCompletionTimeout, setManualAcksMethods inherited from class org.springframework.integration.endpoint.MessageProducerSupportafterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, getRequiredOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpointdoStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, 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 java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.BeanNameAwaresetBeanNameMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.mqtt.core.MqttComponentgetBeanNameMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
Mqttv5PahoMessageDrivenChannelAdapterpublic Mqttv5PahoMessageDrivenChannelAdapter(String url, String clientId, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the MQTT url, client id and subscriptions.- Parameters:
- url- the MQTT url to connect.
- clientId- the unique client id.
- mqttSubscriptions- the MQTT subscriptions.
- Since:
- 6.3
 
- 
Mqttv5PahoMessageDrivenChannelAdapter
- 
Mqttv5PahoMessageDrivenChannelAdapterpublic Mqttv5PahoMessageDrivenChannelAdapter(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the MQTT connection options, client id and subscriptions.- Parameters:
- connectionOptions- the MQTT connection options.
- clientId- the unique client id.
- mqttSubscriptions- the MQTT subscriptions.
- Since:
- 6.3
 
- 
Mqttv5PahoMessageDrivenChannelAdapter
- 
Mqttv5PahoMessageDrivenChannelAdapterpublic Mqttv5PahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager, org.eclipse.paho.mqttv5.common.MqttSubscription... mqttSubscriptions) Create an instance based on the client manager and subscriptions.- Parameters:
- clientManager- The client manager.
- mqttSubscriptions- the MQTT subscriptions.
- Since:
- 6.3
 
- 
Mqttv5PahoMessageDrivenChannelAdapterpublic Mqttv5PahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager, String... topic) Use this constructor when you need to use a singleClientManager(for instance, to reuse an MQTT connection).- Parameters:
- clientManager- The client manager.
- topic- The topic(s).
- Since:
- 6.0
 
 
- 
- 
Method Details- 
getConnectionInfopublic org.eclipse.paho.mqttv5.client.MqttConnectionOptions getConnectionInfo()Description copied from interface:MqttComponentReturn information about the connection.- Specified by:
- getConnectionInfoin interface- MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
- Returns:
- the information.
 
- 
setPersistencepublic void setPersistence(@Nullable org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence) 
- 
setConverter- Overrides:
- setConverterin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
 
- 
setMessageConverter
- 
setPayloadTypeSet the type of the target message payload to produce after conversion from MQTT message. Defaults tobyte[].class- just extract MQTT message payload without conversion. Can be set toMqttMessageclass to produce the whole MQTT message as a payload.- Parameters:
- payloadType- the expected payload type to convert MQTT message to.
 
- 
setHeaderMapperpublic void setHeaderMapper(HeaderMapper<org.eclipse.paho.mqttv5.common.packet.MqttProperties> headerMapper) 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
 
- 
doStartprotected void doStart()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Overrides:
- doStartin class- MessageProducerSupport
 
- 
doStopprotected void doStop()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
- doStopin class- MessageProducerSupport
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Specified by:
- destroyin interface- IntegrationManagement
- Overrides:
- destroyin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
 
- 
setQospublic void setQos(int... qos) Description copied from class:AbstractMqttMessageDrivenChannelAdapterSet the QoS for each topic; a single value will apply to all topics otherwise the correct number of qos values must be provided.- Overrides:
- setQosin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
- Parameters:
- qos- The qos value(s).
 
- 
addTopicDescription copied from class:AbstractMqttMessageDrivenChannelAdapterAdd a topic to the subscribed list.- Overrides:
- addTopicin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
- Parameters:
- topic- The topic.
- qos- The qos.
 
- 
removeTopicDescription copied from class:AbstractMqttMessageDrivenChannelAdapterRemove a topic (or topics) from the subscribed list.- Overrides:
- removeTopicin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,- org.eclipse.paho.mqttv5.client.MqttConnectionOptions> 
- Parameters:
- topic- The topic.
 
- 
messageArrived- Specified by:
- messageArrivedin interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
- 
disconnectedpublic void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) - Specified by:
- disconnectedin interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
- 
mqttErrorOccurredpublic void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) - Specified by:
- mqttErrorOccurredin interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
- 
deliveryCompletepublic void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) - Specified by:
- deliveryCompletein interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
- 
connectCompletepublic void connectComplete(boolean isReconnect) Description copied from interface:ClientManager.ConnectCallbackCalled when the connection to the server is completed successfully.- Specified by:
- connectCompletein interface- ClientManager.ConnectCallback
- Parameters:
- isReconnect- if true, the connection was the result of automatic reconnect.
 
- 
connectComplete- Specified by:
- connectCompletein interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
- 
authPacketArrivedpublic void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
- authPacketArrivedin interface- org.eclipse.paho.mqttv5.client.MqttCallback
 
 
-