|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xenqtt.client.PublishMessage
public class PublishMessage
Message published either by the client to a topic or published to the client from subscribed topic. Users may extend this class to add user defined data.
This can be especially useful when using the AsyncMqttClient
.
Constructor Summary | |
---|---|
PublishMessage(String topicName,
QoS qos,
byte[] payload)
Creates a binary message with retain set to false. |
|
PublishMessage(String topicName,
QoS qos,
byte[] payload,
boolean retain)
Creates a binary message. |
|
PublishMessage(String topicName,
QoS qos,
String payload)
Creates a message with a string as the payload with retain set to false. |
|
PublishMessage(String topicName,
QoS qos,
String payload,
boolean retain)
Creates a message with a string as the payload. |
Method Summary | |
---|---|
void |
ack()
Sends an acknowledgment to the broker for this message unless getQoS() is QoS.AT_MOST_ONCE in which case this does nothing. |
byte[] |
getPayload()
|
String |
getPayloadString()
|
QoS |
getQoS()
|
long |
getReceivedTimestamp()
|
String |
getTopic()
|
boolean |
isDuplicate()
|
boolean |
isRetain()
If the Retain flag is set (1), the server should hold on to the message after it has been delivered to the current subscribers. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PublishMessage(String topicName, QoS qos, byte[] payload, boolean retain)
topicName
- The name of the topic to publish to. This may not contain wildcards ('+' and '#')qos
- The level of assurance for delivery.payload
- The payload as a byte array. It is valid to publish a zero length payload.retain
- If the Retain flag is set (1), the broker should hold on to the message after it has been delivered to the current subscribers. This is useful
where publishers send messages on a "report by exception" basis, where it might be some time between messages. This allows new subscribers to
instantly receive data with the retained, or Last Known Good, value. A broker may delete a retained message if it receives a message with a
zero-length payload and the Retain flag set on the same topic.public PublishMessage(String topicName, QoS qos, byte[] payload)
#publish(String, QoS, byte[], boolean)
.
PublishMessage(String, QoS, byte[], boolean)
public PublishMessage(String topicName, QoS qos, String payload)
PublishMessage(String, QoS, byte[], boolean)
.
PublishMessage(String, QoS, byte[], boolean)
public PublishMessage(String topicName, QoS qos, String payload, boolean retain)
PublishMessage(String, QoS, byte[], boolean)
.
PublishMessage(String, QoS, byte[], boolean)
Method Detail |
---|
public long getReceivedTimestamp()
System.currentTimeMillis()
) when the message was received. 0 if this is not a received message.public final String getTopic()
public final byte[] getPayload()
public final String getPayloadString()
public final boolean isRetain()
When a new subscription is established on a topic, the last retained message on that topic should be sent to the subscriber with the Retain flag set. If there is no retained message, nothing is sent
This is useful where publishers send messages on a "report by exception" basis, where it might be some time between messages. This allows new subscribers to instantly receive data with the retained, or Last Known Good, value.
When a server sends a PUBLISH to a client as a result of a subscription that already existed when the original PUBLISH arrived, the Retain flag should not be set, regardless of the Retain flag of the original PUBLISH. This allows a client to distinguish messages that are being received because they were retained and those that are being received "live".
Retained messages should be kept over restarts of the server.
A server may delete a retained message if it receives a message with a zero-length payload and the Retain flag set on the same topic.
public final boolean isDuplicate()
QoS.AT_MOST_ONCE
. The recipient should treat this flag as a
hint as to whether the message may have been previously received. It should not be relied on to detect duplicates.public final QoS getQoS()
public final void ack()
getQoS()
is QoS.AT_MOST_ONCE
in which case this does nothing. This method
is always asynchronous. If called on an instance created by the client to send to the broker this method does nothing.
public String toString()
toString
in class Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |