-
-
Notifications
You must be signed in to change notification settings - Fork 367
Description
Type: Bug
Component: SQS
Description
I've identified an issue with message converter handling in AbstractListenerAnnotationBeanPostProcessor that prevents custom message converters from being applied to @SqsListener methods.
Environment
io.awspring.cloud:spring-cloud-aws-sqs:3.4.2io.awspring.cloud:spring-cloud-aws-sns:3.4.2- Spring Boot
2.7.18
Problem
The issue occurs in the initialization flow of the AbstractListenerAnnotationBeanPostProcessor:
- The
configureDefaultHandlerMethodFactory(DefaultMessageHandlerMethodFactory handlerMethodFactory)method receives aDefaultMessageHandlerMethodFactoryinstance - Its
methodArgumentResolversis initialized with a converter created bycreateCompositeMessageConverter() - While
SqsMessageListenerContainerFactoryallows registering custom message converters, these converters are overridden by the composite converter created in step 2
Expected Behavior
Custom message converters registered in SqsMessageListenerContainerFactory should be used to resolve method arguments in @SqsListener annotated handlers, enabling proper deserialization of complex types (e.g., LocalDateTime with JavaTimeModule).
Actual Behavior
The custom message converters are overridden by createCompositeMessageConverter(), causing deserialization failures for messages that require custom converters.
Code Sample
@SqsListener("${aws.sqs.queue-name}")
public void handle(@Payload CustomEventType event, Acknowledgement acknowledgment) {
// Handler logic
}@ToString
@Getter
class CustomEventType {
private LocalDateTime createdAt;
private String publisherId;
private List<OtherCustomType> elems;
}Steps to Reproduce
- Register a custom message converter (e.g., with
JavaTimeModule) inSqsMessageListenerContainerFactory - Create an
@SqsListenermethod with a@Payloadparameter containingLocalDateTimefields - Send a message to the queue
- Observe deserialization failure despite the custom converter being registered
Impact
This prevents using custom serialization/deserialization logic with @SqsListener methods, requiring workarounds or manual message parsing.
Possible Solution
The createCompositeMessageConverter() method could be modified to include or respect custom converters registered in the container factory, rather than overriding them.
Would appreciate any guidance on the intended design or if this should be addressed in a future release. Happy to provide additional details or submit a PR if helpful.