Package org.springframework.integration.mqtt.core

Examples of org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory


   *
   * @param data String to be transmitted to the Mqtt Broker.
   */
  public void sendData(String data) {
    Assert.hasText(data, "data must not be empty nor null");
    DefaultMqttPahoClientFactory factory;
    MqttClient client = null;
    factory = new DefaultMqttPahoClientFactory();
    factory.setPassword("guest");
    factory.setUserName("foobar");
    MqttMessage mqttMessage = new MqttMessage();
    mqttMessage.setPayload(data.getBytes());
    try {
      client = factory.getClientInstance("tcp://" + host + ":" + port, "guest");
      client.connect();
      client.publish("xd.mqtt.test", mqttMessage);
      try {
        Thread.sleep(1000);
      }
View Full Code Here

TOP

Related Classes of org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.