Publishing and subscribing

Publishing to a topic

Calling Parameters

Parameter
Description

Topic

Name of the Xively channel you want to publish your message on. Xively topics are formatted in the following way: xi/blue/v1/<accountId>/d/<deviceId>/<channel name>

Message

The message you want to send of any data type.
Encoding: UTF-8
Maximum length: 128Kb

QoS

Default level: 0

Retain

Should the message be retained on the server?

Response Parameters

Parameter
Description

ACK (Acknowledgement)

Message successfully published

If an error is encountered, an error message is returned.

Max message size

The Xively service supports a maximum size of 128 Kb per message.

Subscribing to a topic

Subscribing sets up your device to receive messages on a topic. It can only be called once a client has been connected to the server.

Parameter
Description

Topic

Name of the Xively channel you want to subscribe to. Xively topics are formatted in the following way: xi/blue/v1/<accountId>/d/<deviceId>/<channel name>

QoS

Default level: 0

Callbacks
Most libraries and clients have a specific way of implementing the message callback functions, which will be executed when a message is received.

Response Parameters
Each subscription will return an acknowledgment that is set up on the server or the failure code if the subscription is not successful.


What's Next

That's all there is to MQTT. For detailed descriptions, check out the glossary.

MQTT Glossary

Publishing and subscribing