Class Mqttv5PahoMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
org.springframework.integration.mqtt.outbound.Mqttv5PahoMessageHandler
- All Implemented Interfaces:
org.eclipse.paho.mqttv5.client.MqttCallback,org.reactivestreams.Subscriber<org.springframework.messaging.Message<?>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationEventPublisherAware,org.springframework.context.Lifecycle,org.springframework.core.Ordered,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.context.Orderable,org.springframework.integration.IntegrationPattern,MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.TrackableComponent,org.springframework.messaging.MessageHandler,reactor.core.CoreSubscriber<org.springframework.messaging.Message<?>>
public class Mqttv5PahoMessageHandler extends AbstractMqttMessageHandler implements org.eclipse.paho.mqttv5.client.MqttCallback, MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
The
AbstractMqttMessageHandler implementation for MQTT v5.- Since:
- 5.5.5
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
DEFAULT_COMPLETION_TIMEOUT, DISCONNECT_COMPLETION_TIMEOUTFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors Constructor Description Mqttv5PahoMessageHandler(java.lang.String url, java.lang.String clientId)Mqttv5PahoMessageHandler(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, java.lang.String clientId) -
Method Summary
Modifier and Type Method Description voidauthPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties)voidconnectComplete(boolean reconnect, java.lang.String serverURI)voiddeliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)voiddestroy()voiddisconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse)protected voiddoStart()protected voiddoStop()org.eclipse.paho.mqttv5.client.MqttConnectionOptionsgetConnectionInfo()Return information about the connection.protected voidhandleMessageInternal(org.springframework.messaging.Message<?> message)voidmessageArrived(java.lang.String topic, org.eclipse.paho.mqttv5.common.MqttMessage message)voidmqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception)protected voidonInit()protected voidpublish(java.lang.String topic, java.lang.Object mqttMessage, org.springframework.messaging.Message<?> message)voidsetAsync(boolean async)Set to true if you don't want to block when sending messages.voidsetAsyncEvents(boolean asyncEvents)WhensetAsync(boolean)is true, setting this to true enables publication ofMqttMessageSentEventandMqttMessageDeliveredEventto be emitted.voidsetHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.eclipse.paho.mqttv5.common.packet.MqttProperties> headerMapper)voidsetPersistence(org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence)Methods inherited from class org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
getApplicationEventPublisher, getClientId, getClientInstance, getCompletionTimeout, getComponentType, getConverter, getDefaultQos, getDefaultRetained, getDefaultTopic, getDisconnectCompletionTimeout, getQosProcessor, getRetainedProcessor, getTopicProcessor, getUrl, incrementClientInstance, isRunning, setApplicationEventPublisher, setCompletionTimeout, setConverter, setDefaultQos, setDefaultRetained, setDefaultTopic, setDisconnectCompletionTimeout, setQosExpression, setQosExpressionString, setRetainedExpression, setRetainedExpressionString, setTopicExpression, setTopicExpressionString, start, stopMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribeMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, 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.mqtt.core.MqttComponent
getBeanName
-
Constructor Details
-
Mqttv5PahoMessageHandler
public Mqttv5PahoMessageHandler(java.lang.String url, java.lang.String clientId) -
Mqttv5PahoMessageHandler
public Mqttv5PahoMessageHandler(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, java.lang.String clientId)
-
-
Method Details
-
getConnectionInfo
public org.eclipse.paho.mqttv5.client.MqttConnectionOptions getConnectionInfo()Description copied from interface:MqttComponentReturn information about the connection.- Specified by:
getConnectionInfoin interfaceMqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>- Returns:
- the information.
-
setPersistence
public void setPersistence(@Nullable org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence) -
setHeaderMapper
public void setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.eclipse.paho.mqttv5.common.packet.MqttProperties> headerMapper) -
setAsync
public void setAsync(boolean async)Set to true if you don't want to block when sending messages. Default false. When true, message sent/delivered events will be published for reception by a suitably configured 'ApplicationListener' or an event inbound-channel-adapter.- Parameters:
async- true for async.- See Also:
setAsyncEvents(boolean)
-
setAsyncEvents
public void setAsyncEvents(boolean asyncEvents)WhensetAsync(boolean)is true, setting this to true enables publication ofMqttMessageSentEventandMqttMessageDeliveredEventto be emitted. Default false.- Parameters:
asyncEvents- the asyncEvents.
-
onInit
protected void onInit()- Overrides:
onInitin classAbstractMqttMessageHandler
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractMqttMessageHandler
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractMqttMessageHandler
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Specified by:
destroyin interfaceorg.springframework.integration.support.management.IntegrationManagement- Overrides:
destroyin classorg.springframework.integration.handler.MessageHandlerSupport
-
handleMessageInternal
protected void handleMessageInternal(org.springframework.messaging.Message<?> message)- Overrides:
handleMessageInternalin classAbstractMqttMessageHandler
-
publish
protected void publish(java.lang.String topic, java.lang.Object mqttMessage, org.springframework.messaging.Message<?> message)- Specified by:
publishin classAbstractMqttMessageHandler
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token)- Specified by:
deliveryCompletein interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
disconnected
public void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse)- Specified by:
disconnectedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
mqttErrorOccurred
public void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception)- Specified by:
mqttErrorOccurredin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
messageArrived
public void messageArrived(java.lang.String topic, org.eclipse.paho.mqttv5.common.MqttMessage message)- Specified by:
messageArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
connectComplete
public void connectComplete(boolean reconnect, java.lang.String serverURI)- Specified by:
connectCompletein interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties)- Specified by:
authPacketArrivedin interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-