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.eclipse.paho.mqttv5.client.IMqttAsyncClient,org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
org.springframework.integration.mqtt.outbound.Mqttv5PahoMessageHandler
- All Implemented Interfaces:
org.eclipse.paho.mqttv5.client.MqttCallback
,org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Ordered
,ExpressionCapable
,Orderable
,IntegrationPattern
,MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
,NamedComponent
,IntegrationManagement
,ManageableLifecycle
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
public class Mqttv5PahoMessageHandler
extends AbstractMqttMessageHandler<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
AbstractMqttMessageHandler
implementation for MQTT v5.- Since:
- 5.5.5
- Author:
- Artem Bilan, Lucas Bowler, Artem Vozhdayenko
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
DEFAULT_COMPLETION_TIMEOUT, DISCONNECT_COMPLETION_TIMEOUT
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionMqttv5PahoMessageHandler
(String url, String clientId) Mqttv5PahoMessageHandler
(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId) Mqttv5PahoMessageHandler
(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager) Use this constructor when you need to use a singleClientManager
(for instance, to reuse an MQTT connection). -
Method Summary
Modifier and TypeMethodDescriptionvoid
authPacketArrived
(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) void
connectComplete
(boolean reconnect, String serverURI) void
deliveryComplete
(org.eclipse.paho.mqttv5.client.IMqttToken token) void
destroy()
void
disconnected
(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) protected void
doStart()
protected void
doStop()
org.eclipse.paho.mqttv5.client.MqttConnectionOptions
Return information about the connection.protected void
handleMessageInternal
(Message<?> message) void
messageArrived
(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) void
mqttErrorOccurred
(org.eclipse.paho.mqttv5.common.MqttException exception) protected void
onInit()
Subclasses may implement this for initialization logic.protected void
void
setAsync
(boolean async) Set to true if you don't want to block when sending messages.void
setAsyncEvents
(boolean asyncEvents) WhensetAsync(boolean)
is true, setting this to true enables publication ofMqttMessageSentEvent
andMqttMessageDeliveredEvent
to be emitted.void
setHeaderMapper
(HeaderMapper<org.eclipse.paho.mqttv5.common.packet.MqttProperties> headerMapper) void
setPersistence
(org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence) Methods inherited from class org.springframework.integration.mqtt.outbound.AbstractMqttMessageHandler
getApplicationEventPublisher, getClientId, getClientInstance, getClientManager, 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, stop
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.BeanNameAware
setBeanName
Methods inherited from interface reactor.core.CoreSubscriber
currentContext
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.mqtt.core.MqttComponent
getBeanName
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
Mqttv5PahoMessageHandler
-
Mqttv5PahoMessageHandler
public Mqttv5PahoMessageHandler(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId) -
Mqttv5PahoMessageHandler
public Mqttv5PahoMessageHandler(ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient, org.eclipse.paho.mqttv5.client.MqttConnectionOptions> clientManager) Use this constructor when you need to use a singleClientManager
(for instance, to reuse an MQTT connection).- Parameters:
clientManager
- The client manager.- Since:
- 6.0
-
-
Method Details
-
getConnectionInfo
public org.eclipse.paho.mqttv5.client.MqttConnectionOptions getConnectionInfo()Description copied from interface:MqttComponent
Return information about the connection.- Specified by:
getConnectionInfo
in 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(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
public void setAsyncEvents(boolean asyncEvents) WhensetAsync(boolean)
is true, setting this to true enables publication ofMqttMessageSentEvent
andMqttMessageDeliveredEvent
to be emitted. Default false.- Parameters:
asyncEvents
- the asyncEvents.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMqttMessageHandler<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractMqttMessageHandler<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractMqttMessageHandler<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classMessageHandlerSupport
-
handleMessageInternal
- Overrides:
handleMessageInternal
in classAbstractMqttMessageHandler<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
-
publish
- Specified by:
publish
in classAbstractMqttMessageHandler<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) - Specified by:
deliveryComplete
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
disconnected
public void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) - Specified by:
disconnected
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
mqttErrorOccurred
public void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) - Specified by:
mqttErrorOccurred
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
messageArrived
- Specified by:
messageArrived
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
connectComplete
- Specified by:
connectComplete
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
authPacketArrived
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-