GH-3454: From MQTT conversion error - to error ch (#3456)
* GH-3454: From MQTT conversion error - to error ch Fixes https://github.com/spring-projects/spring-integration/issues/3454 The message converter may return null when we try to covert from the MQTT message. The thrown exception may also reset the client connect. * Fix `MqttPahoMessageDrivenChannelAdapter` to catch any conversion errors (including `null` result) and try to send an `ErrorMessage` with that info into the provided `errorChannel`. Otherwise re-throw it as as **Cherry-pick to `5.4.x` & `5.3.x`** * * Apply review language-specific changes
This commit is contained in:
@@ -154,7 +154,7 @@ Starting with version 5.3, you can set the `manualAcks` property to true.
|
||||
Often used to asynchronously acknowledge delivery.
|
||||
When set to `true`, header (`IntegrationMessageHeaderAccessor.ACKNOWLEDGMENT_CALLBACK`) is added to the message with the value being a `SimpleAcknowledgment`.
|
||||
You must invoke the `acknowledge()` method to complete the delivery.
|
||||
See the Javadocs for `IMqppClient` `setManualAcks()` and `messageArrivedComplete()` for more information.
|
||||
See the Javadocs for `IMqttClient` `setManualAcks()` and `messageArrivedComplete()` for more information.
|
||||
For convenience a header accessor is provided:
|
||||
|
||||
====
|
||||
@@ -164,6 +164,9 @@ StaticMessageHeaderAccessor.acknowledgment(someMessage).acknowledge();
|
||||
----
|
||||
====
|
||||
|
||||
Starting with version `5.2.11`, when the message converter throws an exception or returns `null` from the `MqttMessage` conversion, the `MqttPahoMessageDrivenChannelAdapter` sends an `ErrorMessage` into the `errorChannel`, if provided.
|
||||
Re-throws this conversion error otherwise into an MQTT client callback.
|
||||
|
||||
==== Configuring with Java Configuration
|
||||
|
||||
The following Spring Boot application shows an example of how to configure the inbound adapter with Java configuration:
|
||||
|
||||
Reference in New Issue
Block a user