use of org.eclipse.paho.client.mqttv3.IMqttDeliveryToken in project camel by apache.
the class PahoConsumer method doStart.
@Override
protected void doStart() throws Exception {
super.doStart();
String topic = getEndpoint().getTopic();
getEndpoint().getClient().subscribe(topic);
getEndpoint().getClient().setCallback(new MqttCallback() {
@Override
public void connectionLost(Throwable cause) {
LOG.debug("MQTT broker connection lost due " + cause.getMessage(), cause);
}
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
LOG.debug("Message arrived on topic: {} -> {}", topic, message);
Exchange exchange = getEndpoint().createExchange(message, topic);
getAsyncProcessor().process(exchange, new AsyncCallback() {
@Override
public void done(boolean doneSync) {
// noop
}
});
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
LOG.debug("Delivery complete. Token: {}", token);
}
});
}
Aggregations