MQTT
Lightweight messaging protocol ideal for IoT use cases
Overview
Examples & DSL attributes
mqttConsumer:
broker: tcp://127.0.0.1:1883
topic: customers
clientId: jouleCustomerConsumer
username: joule
password: joule
tenant: uk
qos: 1
deserializer:
parser: com.fractalworks.streams.transport.mqtt.CustomerToStreamEventTranslator
compressed: false
batch: falseimport com.fasterxml.jackson.annotation.JsonRootName;
import com.fractalworks.streams.core.data.streams.StreamEvent;
import com.fractalworks.streams.core.exceptions.TranslationException;
import com.fractalworks.streams.sdk.codec.StreamEventParser;
import com.fractalworks.streams.transport.Customer;
import java.util.Collection;
import java.util.Collections;
@JsonRootName(value = "customer parser")
public class CustomerToStreamEventTranslator implements StreamEventParser {
public CustomerToStreamEventTranslator() {
// REQUIRED
}
@Override
public Collection<StreamEvent> translate(Object o) throws TranslationException {
Collection<StreamEvent> events = null;
if(o instanceof Customer customer){
StreamEvent event = new StreamEvent("customer");
event.addValue("id", customer.getId());
event.addValue("firstname", customer.getFirstname());
event.addValue("surname", customer.getSurname());
event.addValue("age", customer.getAge());
events = Collections.singletonList( event);
}
return events;
}
}Attributes schema
Attribute
Description
Data Type
Required
Deserialisation attributes schema
Attribute
Description
Data Type
Required
Deserialiser example
Additional resources
Last updated