Class MqttPahoMessageDrivenChannelAdapter
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.client.mqttv3.IMqttAsyncClient,org.eclipse.paho.client.mqttv3.MqttConnectOptions>
 
org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter
- All Implemented Interfaces:
- org.eclipse.paho.client.mqttv3.MqttCallback,- org.eclipse.paho.client.mqttv3.MqttCallbackExtended,- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- SmartInitializingSingleton,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- Phased,- SmartLifecycle,- ExpressionCapable,- MessageProducer,- IntegrationPattern,- ClientManager.ConnectCallback,- MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>,- MqttPahoComponent,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
public class MqttPahoMessageDrivenChannelAdapter
extends AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,org.eclipse.paho.client.mqttv3.MqttConnectOptions>
implements org.eclipse.paho.client.mqttv3.MqttCallbackExtended, MqttPahoComponent 
Eclipse Paho Implementation. When consuming 
MqttIntegrationEvents
 published by this component use MqttPahoComponent adapter = event.getSourceAsType() to get a
 reference, allowing you to obtain the bean name and MqttConnectOptions. This
 technique allows consumption of events from both inbound and outbound endpoints in the
 same event listener.- 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 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 SummaryConstructorsConstructorDescriptionMqttPahoMessageDrivenChannelAdapter(String url, String clientId, String... topic) Use this constructor when you don't need additionalMqttConnectOptions.MqttPahoMessageDrivenChannelAdapter(String url, String clientId, MqttPahoClientFactory clientFactory, String... topic) Use this constructor for a single url (although it may be overridden if the server URI(s) are provided by theMqttConnectOptions.getServerURIs()provided by theMqttPahoClientFactory).MqttPahoMessageDrivenChannelAdapter(String clientId, MqttPahoClientFactory clientFactory, String... topic) Use this constructor if the server URI(s) are provided by theMqttConnectOptions.getServerURIs()provided by theMqttPahoClientFactory.MqttPahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient, org.eclipse.paho.client.mqttv3.MqttConnectOptions> clientManager, String... topic) Use this constructor when you need to use a singleClientManager(for instance, to reuse an MQTT connection).
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd a topic to the subscribed list.voidconnectComplete(boolean isReconnect) Called when the connection to the server is completed successfully.voidconnectComplete(boolean reconnect, String serverURI) voidconnectionLost(Throwable cause) voiddeliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) voiddestroy()protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.org.eclipse.paho.client.mqttv3.MqttConnectOptionsReturn information about the connection.voidmessageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage) protected voidonInit()Subclasses may implement this for initialization logic.voidremoveTopic(String... topic) Remove a topic (or topics) from the subscribed list.Methods inherited from class org.springframework.integration.mqtt.inbound.AbstractMqttMessageDrivenChannelAdapteraddTopic, addTopics, getApplicationEventPublisher, getClientId, getClientManager, getCompletionTimeout, getComponentType, getConverter, getDisconnectCompletionTimeout, getQos, getTopic, getUrl, isManualAcks, setApplicationEventPublisher, setCompletionTimeout, setConverter, setDisconnectCompletionTimeout, setManualAcks, setQosMethods inherited from class org.springframework.integration.endpoint.MessageProducerSupportafterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, 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, 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 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- 
MqttPahoMessageDrivenChannelAdapterUse this constructor when you don't need additionalMqttConnectOptions.- Parameters:
- url- The URL.
- clientId- The client id.
- topic- The topic(s).
 
- 
MqttPahoMessageDrivenChannelAdapterpublic MqttPahoMessageDrivenChannelAdapter(String url, String clientId, MqttPahoClientFactory clientFactory, String... topic) Use this constructor for a single url (although it may be overridden if the server URI(s) are provided by theMqttConnectOptions.getServerURIs()provided by theMqttPahoClientFactory).- Parameters:
- url- the URL.
- clientId- The client id.
- clientFactory- The client factory.
- topic- The topic(s).
 
- 
MqttPahoMessageDrivenChannelAdapterpublic MqttPahoMessageDrivenChannelAdapter(String clientId, MqttPahoClientFactory clientFactory, String... topic) Use this constructor if the server URI(s) are provided by theMqttConnectOptions.getServerURIs()provided by theMqttPahoClientFactory.- Parameters:
- clientId- The client id.
- clientFactory- The client factory.
- topic- The topic(s).
- Since:
- 4.1
 
- 
MqttPahoMessageDrivenChannelAdapterpublic MqttPahoMessageDrivenChannelAdapter(ClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient, org.eclipse.paho.client.mqttv3.MqttConnectOptions> 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.client.mqttv3.MqttConnectOptions getConnectionInfo()Description copied from interface:MqttComponentReturn information about the connection.- Specified by:
- getConnectionInfoin interface- MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>
- Specified by:
- getConnectionInfoin interface- MqttPahoComponent
- Returns:
- the information.
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,- org.eclipse.paho.client.mqttv3.MqttConnectOptions> 
 
- 
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.client.mqttv3.IMqttAsyncClient,- org.eclipse.paho.client.mqttv3.MqttConnectOptions> 
 
- 
addTopicDescription copied from class:AbstractMqttMessageDrivenChannelAdapterAdd a topic to the subscribed list.- Overrides:
- addTopicin class- AbstractMqttMessageDrivenChannelAdapter<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,- org.eclipse.paho.client.mqttv3.MqttConnectOptions> 
- 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.client.mqttv3.IMqttAsyncClient,- org.eclipse.paho.client.mqttv3.MqttConnectOptions> 
- Parameters:
- topic- The topic.
 
- 
connectionLost- Specified by:
- connectionLostin interface- org.eclipse.paho.client.mqttv3.MqttCallback
 
- 
messageArrived- Specified by:
- messageArrivedin interface- org.eclipse.paho.client.mqttv3.MqttCallback
 
- 
deliveryCompletepublic void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) - Specified by:
- deliveryCompletein interface- org.eclipse.paho.client.mqttv3.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.client.mqttv3.MqttCallbackExtended
 
 
-