You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/sqs.adoc
+41-18Lines changed: 41 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1647,14 +1647,47 @@ public SqsMessageListenerContainerFactory<Object> defaultSqsListenerContainerFac
1647
1647
----
1648
1648
=== Message Conversion and Payload Deserialization
1649
1649
1650
-
Payloads are automatically deserialized from `JSON` for `@SqsListener` annotated methods using a `JacksonJsonMessageConverter` when Jackson 3 is on classpath. If there is no Jackson 3 on classpath and there is Jackson 2 on classpath `MappingJackson2MessageConverter` will be used.
1650
+
Payloads are automatically deserialized from `JSON` for `@SqsListener` annotated methods to the inferred payload type. See <<Automatic Payload Type Inference>> for information on how the payload type is inferred.
1651
1651
1652
-
NOTE: When using Spring Boot's auto-configuration, if there's a single `JsonMapper` in Spring Context, such object mapper will be used for converting messages.
1653
-
This includes the one provided by Spring Boot's auto-configuration itself.
1654
-
For configuring a different `JsonMapper`, see <<Global Configuration for @SqsListeners>>.
1652
+
==== Configuring Payload Deserialization
1655
1653
1656
-
NOTE: When Jackson 3 is not on classpath and only Jackson 2 is found, if there's a single `ObjectMapper` in Spring Context, such object mapper will be used for converting messages.
1657
-
This includes the one provided by Spring Boot's auto-configuration itself.
1654
+
Payload conversion for `@SqsListener` methods is performed by a `SqsMessagingMessageConverter` by default.
1655
+
1656
+
If message conversion customization is necessary, the `SqsMessagingMessageConverter` provided by auto-configuration can be overridden by declaring a `MessagingMessageConverter` bean, or by configuring it through `SqsMessageListenerContainerFactory` and its `ContainerOptions`.
return new SqsMessagingMessageConverter(jsonMapper);
1677
+
}
1678
+
----
1679
+
1680
+
NOTE: When using Spring Boot's auto-configuration, if there is a single `JsonMapper` in the Spring context, that `JsonMapper` will be used for converting messages. This includes the one provided by Spring Boot's auto-configuration itself.
1681
+
1682
+
==== Jackson Migration
1683
+
1684
+
During the Jackson migration period, if Jackson 3 is on the classpath, a `JacksonJsonMessageConverter` will be used.
1685
+
If only Jackson 2 is on the classpath, `MappingJackson2MessageConverter` will be used.
1686
+
1687
+
When using Jackson 2, if there is a single `ObjectMapper` in the Spring context, that `ObjectMapper` will be used for converting messages.
1688
+
1689
+
While auto-selection should be sufficient for most users, if both Jackson 2 and Jackson 3 are present on the classpath and Jackson 2-based conversion is required, a temporary workaround is to declare a `LegacyJackson2SqsMessagingMessageConverter` bean for payload deserialization and/or a `LegacyJackson2MessageConverterMigration` bean for the default listener method argument resolvers.
1690
+
These workarounds are transitional and not a long-term supported contract.
1658
1691
1659
1692
==== Automatic Payload Type Inference
1660
1693
@@ -2050,26 +2083,16 @@ The following attributes can be configured in the registrar:
2050
2083
- `setMessageHandlerMethodFactory` - provide a different factory to be used to create the `invocableHandlerMethod` instances that wrap the listener methods.
2051
2084
- `setListenerContainerRegistry` - provide a different `MessageListenerContainerRegistry` implementation to be used to register the `MessageListenerContainers`
2052
2085
- `setMessageListenerContainerRegistryBeanName` - provide a different bean name to be used to retrieve the `MessageListenerContainerRegistry`
2053
-
- `setJacksonMessageConverterMigration` - set the `JacksonMessageConverterMigration` which will be used to construct `MessageConverter` and provide either `JsonMapper` for Jackson 3 or `ObjectMapper` for Jackson 2. Check `JacksonJsonMessageConverterMigration` and `LegacyJackson2MessageConverterMigration`
2054
-
See <<Message Conversion and Payload Deserialization>> for more information on where this is used.
2086
+
- `setJacksonMessageConverterMigration` - internal migration wiring for the Jackson 2 to Jackson 3 transition, not intended for application configuration.
2055
2087
- `setValidator` - set the `Validator` instance that will be used for payload validation in listener methods.
2056
-
- `manageMessageConverters` - gives access to the list of message converters that will be used to convert messages.
2088
+
- `manageMessageConverters` - gives access to the list of message converters that will be used by ArgumentResolvers.
2057
2089
By default, `StringMessageConverter`, `SimpleMessageConverter` and `JacksonJsonMessageConverter` are used.
2058
2090
2059
2091
- `manageArgumentResolvers` - gives access to the list of argument resolvers that will be used to resolve the listener method arguments.
2060
-
The order of resolvers is important - `PayloadMethodArgumentResolver` should generally be last since it's used as default.
2061
2092
- `setMethodPayloadTypeInferrer` - set the `MethodPayloadTypeInferrer` instance to be used for automatic payload type inference.
2062
2093
Set to `null` to disable automatic inference and rely on header-based type mapping.
2063
2094
See <<Automatic Payload Type Inference>> for more information.
Copy file name to clipboardExpand all lines: spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/support/converter/legacy/JacksonJsonMessageConverterMigration.java
Copy file name to clipboardExpand all lines: spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/support/converter/legacy/JacksonMessageConverterMigration.java
Copy file name to clipboardExpand all lines: spring-cloud-aws-sqs/src/main/java/io/awspring/cloud/sqs/support/converter/legacy/LegacyJackson2MessageConverterMigration.java
0 commit comments