GH-3215: MQTT Event for failed connection outbound

Resolves https://github.com/spring-projects/spring-integration/issues/3215

* Add docs; publish an event for an initial connection failure too.

**Cherry-pick to 5.2.x**
This commit is contained in:
Gary Russell
2020-03-17 15:09:22 -04:00
committed by GitHub
parent 92421f7575
commit eea29e729a
3 changed files with 28 additions and 1 deletions

View File

@@ -278,7 +278,7 @@ The default is `headers['mqtt_topic']`.
<11> When `true`, the caller does not block.
Rather, it waits for delivery confirmation when a message is sent.
The default is `false` (the send blocks until delivery is confirmed).
<12> When `async` and `async-events` are both `true`, an `MqttMessageSentEvent` is emitted.
<12> When `async` and `async-events` are both `true`, an `MqttMessageSentEvent` is emitted (See <<events>>).
It contains the message, the topic, the `messageId` generated by the client library, the `clientId`, and the `clientInstance` (incremented each time the client is connected).
When the delivery is confirmed by the client library, an `MqttMessageDeliveredEvent` is emitted.
It contains the the `messageId`, the `clientId`, and the `clientInstance`, enabling delivery to be correlated with the send.
@@ -372,3 +372,14 @@ public class MqttJavaApplication {
}
----
====
[[events]]
=== Events
Certain application events are published by the adapters.
* `MqttConnectionFailedEvent` - published by both adapters if we fail to connect or a connection is subsequently lost.
* `MqttMessageSentEvent` - published by the outbound adapter when a message has been sent, if running in asynchronous mode.
* `MqttMessageDeliveredEvent` - published by the outbound adapter when the client indicates that a message has been delivered, if running in asynchronous mode.
These events can be received by an `ApplicationListener<MqttIntegrationEvent>` or with an `@EventListener` method.