public class MqttPahoMessageHandler extends AbstractMqttMessageHandler implements org.eclipse.paho.client.mqttv3.MqttCallback, MqttPahoComponent, ApplicationEventPublisherAware
MqttIntegrationEvent
s
published by this component use MqttPahoComponent handler = 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.IntegrationManagement.ManagementOverrides
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.
|
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
MqttPahoMessageHandler(String clientId,
MqttPahoClientFactory clientFactory)
Use this constructor if the server URI(s) are provided by the
MqttConnectOptions.getServerURIs()
provided by the MqttPahoClientFactory . |
MqttPahoMessageHandler(String url,
String clientId)
Use this constructor when you don't need additional
MqttConnectOptions . |
MqttPahoMessageHandler(String url,
String clientId,
MqttPahoClientFactory clientFactory)
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 ). |
Modifier and Type | Method and Description |
---|---|
void |
connectionLost(Throwable cause) |
void |
deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) |
protected void |
doStart() |
protected void |
doStop() |
org.eclipse.paho.client.mqttv3.MqttConnectOptions |
getConnectionInfo()
Return information about the connection.
|
void |
messageArrived(String topic,
org.eclipse.paho.client.mqttv3.MqttMessage message) |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected void |
publish(String topic,
Object mqttMessage,
Message<?> message) |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAsync(boolean async)
Set to true if you don't want to block when sending messages.
|
void |
setAsyncEvents(boolean asyncEvents)
When
setAsync(boolean) is true, setting this to true enables
publication of MqttMessageSentEvent and MqttMessageDeliveredEvent
to be emitted. |
void |
setCompletionTimeout(long completionTimeout)
Set the completion timeout for async operations.
|
void |
setDisconnectCompletionTimeout(long completionTimeout)
Set the completion timeout when disconnecting.
|
getClientId, getClientInstance, getComponentType, getConverter, getUrl, handleMessageInternal, incrementClientInstance, isRunning, setConverter, setDefaultQos, setDefaultRetained, setDefaultTopic, setQosExpression, setQosExpressionString, setRetainedExpression, setRetainedExpressionString, setTopicExpression, setTopicExpressionString, start, stop
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
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
getThisAs
getBeanName, getComponentName
public static final long DEFAULT_COMPLETION_TIMEOUT
public static final long DISCONNECT_COMPLETION_TIMEOUT
public MqttPahoMessageHandler(String url, String clientId, MqttPahoClientFactory clientFactory)
MqttConnectOptions.getServerURIs()
provided by
the MqttPahoClientFactory
).url
- the URL.clientId
- The client id.clientFactory
- The client factory.public MqttPahoMessageHandler(String clientId, MqttPahoClientFactory clientFactory)
MqttConnectOptions.getServerURIs()
provided by the MqttPahoClientFactory
.clientId
- The client id.clientFactory
- The client factory.public void setAsync(boolean async)
async
- true for async.public void setAsyncEvents(boolean asyncEvents)
setAsync(boolean)
is true, setting this to true enables
publication of MqttMessageSentEvent
and MqttMessageDeliveredEvent
to be emitted. Default false.asyncEvents
- the asyncEvents.public void setCompletionTimeout(long completionTimeout)
completionTimeout
- The timeout.public void setDisconnectCompletionTimeout(long completionTimeout)
completionTimeout
- The timeout.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 onInit()
IntegrationObjectSupport
onInit
in class AbstractMqttMessageHandler
protected void doStart()
doStart
in class AbstractMqttMessageHandler
protected void doStop()
doStop
in class AbstractMqttMessageHandler
protected void publish(String topic, Object mqttMessage, Message<?> message)
publish
in class AbstractMqttMessageHandler
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 message)
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