com.supermap.messagequeue
Class MQTTClient
- java.lang.Object
-
- com.supermap.messagequeue.InternalHandle
-
- com.supermap.messagequeue.MQTTClient
-
public class MQTTClient extends InternalHandle
The MQTT client class, based on message bus of MQTT protocol.The use of theme subscription to achieve the mechanism of messaging,
-
-
Constructor Summary
Constructors Constructor and Description MQTTClient()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description boolean
create(java.lang.String uri, java.lang.String userName, java.lang.String password, java.lang.String clientID)
Creates connection.void
dispose()
Destructor, release resourceMQTTReturnMessage
receiveMessage()
Receive the message You need to perform this operation on a child threadvoid
resume()
Resume.boolean
sendMessage(java.lang.String topic, java.lang.String message)
Send a messageboolean
subscribe(java.lang.String topicName, int qos)
Subscribes a topic.void
suspend()
Suspend.boolean
unsubscribe(java.lang.String topicName)
Cancels a topic of subscription.
-
-
-
Method Detail
-
create
public boolean create(java.lang.String uri, java.lang.String userName, java.lang.String password, java.lang.String clientID)
Creates connection.- Parameters:
uri
- Service addressuserName
- usernamepassword
- user passwordclientID
- Client ID- Returns:
- Returns true if the creation succeeds, false otherwise
-
dispose
public void dispose()
Destructor, release resource
-
subscribe
public boolean subscribe(java.lang.String topicName, int qos)
Subscribes a topic.- Parameters:
topicName
- Subject nameqos
- Message quality- Returns:
- Returns true if the subscription succeeds, false otherwise
-
unsubscribe
public boolean unsubscribe(java.lang.String topicName)
Cancels a topic of subscription.- Parameters:
topicName
- Subject name- Returns:
- Returns whether or not to cancel successfully
-
sendMessage
public boolean sendMessage(java.lang.String topic, java.lang.String message)
Send a message- Parameters:
topic
- Subject namemessage
- Message content- Returns:
- Returns true if sent successfully, false otherwise
-
receiveMessage
public MQTTReturnMessage receiveMessage()
Receive the messageYou need to perform this operation on a child thread
- Returns:
- Received message
-
resume
public void resume()
Resume.
-
suspend
public void suspend()
Suspend.
-
-