| java.lang.Object |
| ↳ |
org.mule.modules.mqtt.MqttConnector |
Known Direct Subclasses
|
Known Indirect Subclasses
|
Class Overview
Mule MQTT Module.
{@sample.config INCLUDE_ERROR}
{@sample.config INCLUDE_ERROR}
Summary
| Nested Classes |
|
enum |
MqttConnector.DeliveryQoS |
|
|
[Expand]
Inherited Methods |
From class
java.lang.Object
|
Object
|
clone()
|
|
boolean
|
equals(Object arg0)
|
|
void
|
finalize()
|
|
final
Class<?>
|
getClass()
|
|
int
|
hashCode()
|
|
final
void
|
notify()
|
|
final
void
|
notifyAll()
|
|
String
|
toString()
|
|
final
void
|
wait()
|
|
final
void
|
wait(long arg0, int arg1)
|
|
final
void
|
wait(long arg0)
|
|
From interface
org.mule.api.context.MuleContextAware
|
abstract
void
|
setMuleContext(MuleContext arg0)
|
|
Constants
public
static
final
String
MQTT_DEFAULT_BROKER_URI
Constant Value:
"tcp://localhost:1883"
private
static
final
String
MQTT_DEFAULT_QOS_STRING
Constant Value:
"AT_LEAST_ONCE"
public
static
final
String
MQTT_DELIVERY_TOKEN_VARIABLE
Constant Value:
"mqtt.deliveryToken"
public
static
final
String
MQTT_PROPERTIES_PREFIX
public
static
final
String
MQTT_QOS_PROPERTY
Constant Value:
"mqtt.qos"
public
static
final
String
MQTT_TOPIC_NAME_PROPERTY
Constant Value:
"mqtt.topicName"
Fields
private
static
final
Log
LOGGER
private
String
brokerServerUri
private
boolean
cleanSession
private
MqttClient
client
private
MqttConnectOptions
connectOptions
private
int
connectionTimeout
private
int
keepAliveInterval
private
String
lwtMessage
Last Will and Testimate message.
private
int
lwtQos
Last Will and Testimate QOS.
private
boolean
lwtRetained
Last Will and Testimate retention.
private
String
lwtTopicName
Last Will and Testimate Topic
private
MuleContext
muleContext
private
String
password
Password to log into broker with.
private
String
persistenceLocation
Directory on the machine where message persistence can be stored to disk.
private
String
username
Username to log into broker with.
Public Constructors
Public Methods
public
void
connect
(String clientId)
Connects the MQTT client.
Parameters
| clientId
| Client identifier for the broker.
|
public
void
disconnect
()
public
String
getActiveClientId
()
public
String
getBrokerServerUri
()
public
int
getConnectionTimeout
()
public
int
getKeepAliveInterval
()
public
String
getLwtMessage
()
public
String
getLwtTopicName
()
public
MqttClient
getMqttClient
()
public
MuleContext
getMuleContext
()
public
String
getPassword
()
public
String
getPersistenceLocation
()
public
String
getUsername
()
public
boolean
isCleanSession
()
public
boolean
isConnected
()
public
boolean
isLwtRetained
()
public
byte[]
publish
(String topicName, Long waitForCompletionTimeOut, MqttConnector.DeliveryQoS qos, byte[] messagePayload, MuleEvent muleEvent)
Publish a message to a topic. If sucessful a flow variable named
MQTT_DELIVERY_TOKEN_VARIABLE will contain the MqttDeliveryToken
that can be used for further awaiting completion.
Parameters
| topicName
| Topic to publish message to. |
| waitForCompletionTimeOut
| Time in milliseconds to wait for the delivery to occur. |
| qos
| QoS level to use when publishing message. |
| messagePayload
| The payload that will be published over MQTT. |
| muleEvent
| The in-flight MuleEvent. |
Returns
- the
byte[] that was published.
Throws
| MqttException
| thrown if the MQTT publish fails.
|
public
void
setBrokerServerUri
(String brokerServerUri)
public
void
setCleanSession
(boolean cleanSession)
public
void
setConnectionTimeout
(int connectionTimeout)
public
void
setKeepAliveInterval
(int keepAliveInterval)
public
void
setLwtMessage
(String lwtMessage)
public
void
setLwtQos
(int lwtQos)
public
void
setLwtRetained
(boolean lwtRetained)
public
void
setLwtTopicName
(String lwtTopicName)
public
void
setMuleContext
(MuleContext muleContext)
public
void
setPassword
(String password)
public
void
setPersistenceLocation
(String persistenceLocation)
public
void
setUsername
(String username)
public
void
subscribe
(String topicFilter, MqttConnector.DeliveryQoS qos, List<MqttTopicSubscription> topicSubscriptions, SourceCallback callback)
Subscribe to a single or multiple topic filters.
Parameters
| topicFilter
| Single topic filter to subscribe to. |
| qos
| QoS level to use when subscribing to a single topic. |
| topicSubscriptions
| A List of MqttTopicSubscription to subscribe to. |
| callback
| The SourceCallback used by Mule to dispatch the received messages. |
Throws
| ConnectionException
| thrown if the MQTT subscribe fails.
|