Search in sources :

Example 1 with MqttMessageSentEvent

use of org.springframework.integration.mqtt.event.MqttMessageSentEvent in project spring-integration by spring-projects.

the class MqttPahoMessageHandler method publish.

@Override
protected void publish(String topic, Object mqttMessage, Message<?> message) throws Exception {
    Assert.isInstanceOf(MqttMessage.class, mqttMessage);
    IMqttAsyncClient client = checkConnection();
    IMqttDeliveryToken token = client.publish(topic, (MqttMessage) mqttMessage);
    if (!this.async) {
        token.waitForCompletion(this.completionTimeout);
    } else if (this.asyncEvents && this.applicationEventPublisher != null) {
        this.applicationEventPublisher.publishEvent(new MqttMessageSentEvent(this, message, topic, token.getMessageId(), getClientId(), getClientInstance()));
    }
}
Also used : MqttMessageSentEvent(org.springframework.integration.mqtt.event.MqttMessageSentEvent) IMqttDeliveryToken(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken) IMqttAsyncClient(org.eclipse.paho.client.mqttv3.IMqttAsyncClient)

Aggregations

IMqttAsyncClient (org.eclipse.paho.client.mqttv3.IMqttAsyncClient)1 IMqttDeliveryToken (org.eclipse.paho.client.mqttv3.IMqttDeliveryToken)1 MqttMessageSentEvent (org.springframework.integration.mqtt.event.MqttMessageSentEvent)1