All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.computate.smartvillage.enus.mqtt.MqttMessageReader Maven / Gradle / Ivy

Go to download

Red Hat Global Social Innovation Program is partnering with Boston University and Smarta Byar in order to collaborate on creating a global and open research platform allowing researchers to study what social sustainability means by using a digital twin of Veberöd, Sweden as the test village, supported by Smarta Byar. The goal of this collaboration is to build the open source technological infrastructure so that researchers can collaborate on this platform effectively to study mobility, public health, sustainability among other study areas to ultimately help define better the link between well being and eco-smart cities.

There is a newer version: 2.0.2
Show newest version
/*
 * Copyright (c) 2018-2022 Computate Limited Liability Company in Utah, USA,
 * and the Smarta Byar Smart Village FIWARE IHub. 
 *
 * This program and the accompanying materials are made available under the
 * terms of the GNU GENERAL PUBLIC LICENSE Version 3 which is available at
 * 
 * https://www.gnu.org/licenses/gpl-3.0.en.html
 * 
 * You may not propagate or modify a covered work except as expressly provided 
 * under this License. Any attempt otherwise to propagate or modify it is void, 
 * and will automatically terminate your rights under this License (including 
 * any patent licenses granted under the third paragraph of section 11).
 */
package org.computate.smartvillage.enus.mqtt;

import org.computate.smartvillage.enus.config.ConfigKeys;

import io.vertx.core.json.JsonObject;
import io.vertx.mqtt.MqttClient;

public class MqttMessageReader {

	public final static Integer MQTT_QOS_AT_MOST_ONCE = 0;
	public final static Integer MQTT_QOS_AT_LEAST_ONCE = 1;
	public final static Integer MQTT_QOS_EXACTLY_ONCE = 2;

	public MqttMessageReader(MqttClient mqttClient, JsonObject config) {
		mqttClient.publishHandler(message -> {
			System.out.println("There are new message in topic: " + message.topicName());
			System.out.println("Content(as string) of the message: " + message.payload().toString());
			System.out.println("QoS: " + message.qosLevel());
		}).subscribe(config.getString(ConfigKeys.MQTT_IOT_SUBSCRIBE_TOPIC), MQTT_QOS_EXACTLY_ONCE);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy