Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3EventNotification deserialization no longer works with AWS SDK v2 S3 Event Notification #1278

Open
helpermethod opened this issue Nov 20, 2024 · 3 comments
Labels
component: sqs SQS integration related issue

Comments

@helpermethod
Copy link

helpermethod commented Nov 20, 2024

Type: Bug

Component:
SQS

Describe the bug
S3EventNotification is no longer correctly deserialized when switching from com.amazonaws:aws-java-sdk-s3 to software.amazon.awssdk:s3-event-notifications.

This is due to the following changes: https://aws.amazon.com/de/blogs/developer/the-aws-sdk-for-java-2-17-removes-its-external-dependency-on-jackson/

Because the constructor and fields are no longer annotated with @JsonCreator and @JsonProperty, Jackson is no longer able to map the JSON correctly.

It's easy to work around it by accepting a String instead of a S3EventNotification in the listener and then performing the deserialization by calling S3EventNotification.fromJson but it would be nicer this wouldn't be needed.

@SqsListener("\${sqs.currents.notifications.processed.queueName}")
fun listen(s3EventNotificationJson: String) {
    val s3EventNotification = S3EventNotification.fromJson(s3EventNotificationJson)

    copyService.copy(s3EventNotification.records.first())
}

One solution could be to provide a custom JSON Deserializer for that case. Wouldn't mind creating a PR.

@helpermethod helpermethod changed the title S3EventNotification Deserialization no longer works with AWS SDK v2 S3 Event Notification S3EventNotification deserialization no longer works with AWS SDK v2 S3 Event Notification Nov 20, 2024
@tomazfernandes
Copy link
Contributor

Hey @helpermethod, thanks for bringing this up, your PR is welcome!

@tomazfernandes
Copy link
Contributor

Just one comment @helpermethod - if I understand the feature correctly, I think the best way to handle this might be having an ArgumentResolver, similar to what we do with AcknowledgmentHandlerMethodArgumentResolver.

Makes sense?

@tomazfernandes tomazfernandes added the component: sqs SQS integration related issue label Nov 20, 2024
@helpermethod
Copy link
Author

helpermethod commented Nov 22, 2024

Hi @tomazfernandes,

I guess I also need to register the argument resolver in AbstractListenerAnnotationBeanPostProcessor?

Furthermore: Would it make sense to include software.amazon.awssdk:s3-event-notifications as a dependency as S3EventNotification already provides methods for converting from/to JSON?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue
Projects
None yet
Development

No branches or pull requests

2 participants