public class MqttPahoMessageDrivenChannelAdapter extends AbstractMqttMessageDrivenChannelAdapter implements org.eclipse.paho.client.mqttv3.MqttCallback, MqttPahoComponent, ApplicationEventPublisherAware
MqttIntegrationEvent
s
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.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_COMPLETION_TIMEOUT
The default completion timeout in milliseconds.
|
static long |
DISCONNECT_COMPLETION_TIMEOUT
The default disconnect completion timeout in milliseconds.
|
topicLock
lifecycleCondition, lifecycleLock
EXPRESSION_PARSER, logger
DEFAULT_PHASE
Constructor and Description |
---|
MqttPahoMessageDrivenChannelAdapter(String clientId,
MqttPahoClientFactory clientFactory,
String... topic)
Use this constructor if the server URI(s) are provided by the
MqttConnectOptions.getServerURIs() provided by the
MqttPahoClientFactory . |
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 the
MqttConnectOptions.getServerURIs() provided by
the MqttPahoClientFactory ). |
MqttPahoMessageDrivenChannelAdapter(String url,
String clientId,
String... topic)
Use this constructor when you don't need additional
MqttConnectOptions . |
Modifier and Type | Method and Description |
---|---|
void |
addTopic(String topic,
int qos)
Add a topic to the subscribed list.
|
void |
connectionLost(Throwable cause) |
void |
deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) |
protected void |
doStart()
Take no action by default.
|
protected void |
doStop()
Take no action by default.
|
org.eclipse.paho.client.mqttv3.MqttConnectOptions |
getConnectionInfo()
Return information about the connection.
|
void |
messageArrived(String topic,
org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage) |
void |
removeTopic(String... topic)
Remove a topic (or topics) from the subscribed list.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setCompletionTimeout(long completionTimeout)
Set the completion timeout for operations.
|
void |
setDisconnectCompletionTimeout(long completionTimeout)
Set the completion timeout when disconnecting.
|
void |
setManualAcks(boolean manualAcks)
Set the acknowledgment mode to manual.
|
void |
setRecoveryInterval(int recoveryInterval)
The time (ms) to wait between reconnection attempts.
|
addTopic, addTopics, getClientId, getComponentType, getConverter, getQos, getTopic, getUrl, onInit, setConverter, setQos
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBeanName
setBeanName
getBeanName, getComponentName
public static final long DEFAULT_COMPLETION_TIMEOUT
public static final long DISCONNECT_COMPLETION_TIMEOUT
public MqttPahoMessageDrivenChannelAdapter(String url, String clientId, MqttPahoClientFactory clientFactory, String... topic)
MqttConnectOptions.getServerURIs()
provided by
the MqttPahoClientFactory
).url
- the URL.clientId
- The client id.clientFactory
- The client factory.topic
- The topic(s).public MqttPahoMessageDrivenChannelAdapter(String clientId, MqttPahoClientFactory clientFactory, String... topic)
MqttConnectOptions.getServerURIs()
provided by the
MqttPahoClientFactory
.clientId
- The client id.clientFactory
- The client factory.topic
- The topic(s).public void setCompletionTimeout(long completionTimeout)
completionTimeout
- The timeout.public void setDisconnectCompletionTimeout(long completionTimeout)
completionTimeout
- The timeout.public void setRecoveryInterval(int recoveryInterval)
recoveryInterval
- the interval.public void setManualAcks(boolean manualAcks)
manualAcks
- true for manual acks.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
public org.eclipse.paho.client.mqttv3.MqttConnectOptions getConnectionInfo()
MqttComponent
getConnectionInfo
in interface MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>
getConnectionInfo
in interface MqttPahoComponent
protected void doStart()
MessageProducerSupport
doStart
in class MessageProducerSupport
protected void doStop()
MessageProducerSupport
doStop
in class MessageProducerSupport
public void addTopic(String topic, int qos)
AbstractMqttMessageDrivenChannelAdapter
addTopic
in class AbstractMqttMessageDrivenChannelAdapter
topic
- The topic.qos
- The qos.public void removeTopic(String... topic)
AbstractMqttMessageDrivenChannelAdapter
removeTopic
in class AbstractMqttMessageDrivenChannelAdapter
topic
- The topic.public void connectionLost(Throwable cause)
connectionLost
in interface org.eclipse.paho.client.mqttv3.MqttCallback
public void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
messageArrived
in interface org.eclipse.paho.client.mqttv3.MqttCallback
public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
deliveryComplete
in interface org.eclipse.paho.client.mqttv3.MqttCallback