org.eclipse.paho.client.mqttv3
Class MqttTopic

java.lang.Object
  extended byorg.eclipse.paho.client.mqttv3.MqttTopic

public class MqttTopic
extends java.lang.Object

Represents a topic destination, used for publish/subscribe messaging.


Method Summary
 java.lang.String getName()
          Returns the name of the queue or topic.
 MqttDeliveryToken publish(byte[] payload, int qos, boolean retained)
          Publishes a message on the topic.
 MqttDeliveryToken publish(MqttMessage message)
          Publishes the specified message to this topic, but doesn't wait for a response.
 java.lang.String toString()
          Returns a string representation of this topic.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

publish

public MqttDeliveryToken publish(byte[] payload,
                                 int qos,
                                 boolean retained)
                          throws MqttException,
                                 MqttPersistenceException
Publishes a message on the topic. This is a convenience method, which will create a new MqttMessage object with a byte array payload and the specified QoS, and then publish it. All other values in the message will be set to the defaults.

Parameters:
payload - the byte array to use as the payload
qos - the Quality of Service. Valid values are 0, 1 or 2.
retained - whether or not this message should be retained by the server.
Throws:
java.lang.IllegalArgumentException - if value of QoS is not 0, 1 or 2.
MqttException
MqttPersistenceException
See Also:
publish(MqttMessage), MqttMessage.setQos(int), MqttMessage.setRetained(boolean)

publish

public MqttDeliveryToken publish(MqttMessage message)
                          throws MqttException,
                                 MqttPersistenceException
Publishes the specified message to this topic, but doesn't wait for a response. The returned token can be used to track the delivery status of the message. Once this message has returned cleanly, the message has been accepted for publication by the client - as long as a connection is available, it will try and deliver it.

Parameters:
message - the message to publish
Returns:
an MqttDeliveryToken for tracking the delivery of the message
Throws:
MqttException
MqttPersistenceException

getName

public java.lang.String getName()
Returns the name of the queue or topic.

Returns:
the name of this destination.

toString

public java.lang.String toString()
Returns a string representation of this topic.

Returns:
a string representation of this topic.