bundle provides the Java
™ client. It provides publish and subscribe capabilities to both topic and queue destinations. It also allows user properties to be added to messages and to support formatted payloads.
Example usage of the Java API
The following code snippet, using the API, shows how to connect to the broker, publish one message, and then disconnect. Note that the code excerpt does not show all the Java™ exception handling that might be required.
Parent topic: Developing an application using the MQTT API
MqttClient client = new MqttClient("tcp://localhost:1883");
client.getTopic("foo/bar").publish(new MqttMessage("Hello world"));