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

JsonParseException when I try to add Acknowledgement in SqsListener #844

Closed
sfc-gh-ycao opened this issue Jul 5, 2023 · 3 comments
Closed

Comments

@sfc-gh-ycao
Copy link

sfc-gh-ycao commented Jul 5, 2023

Type: Bug

Component: SQS

Describe the bug
Version: 3.0.1
When I try to add Acknowledgment in my SqsListener function, it will throw JsonParseException

Sample

@SqsListener(value = "http://localhost:4566/000000000000/test")
    public void processAccount(SqsMessage sqsMessage, Acknowledgment acknowledgment) {
        try {
            processConnectivityTest(sqsMessage);
            // acknowledgment.acknowledge();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

This will throw error
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'SqsMessage': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

@SqsListener(value = "http://localhost:4566/000000000000/test")
    public void processAccount(SqsMessage sqsMessage) {
        try {
            processConnectivityTest(sqsMessage);
            System.out.println("Message: " + sqsMessage.toString());
            // acknowledgment.acknowledge();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

But this will not.

@nedconveylaw
Copy link

I am experiencing the same, but only for messages that I send to the queue, receiving messages from an AWS source such as an S3 event is correctly deserialized.

When debugging all I can find is that convertFromInternal in MappingJackson2MessageConverter tries to deserialize the deserialized payload using the objects .toString() method, which errors with the Jackson error that it can't parse it as JSON.

When looking at the objects in the debug console, it appears as though the deserialized payload isn't assignable to the required class, however the class types look the same.

@tomazfernandes
Copy link
Contributor

@nedconveylaw, from your description this seems to be related to an issue with DevTools.

@sfc-gh-ycao , are you using Spring DevTools, and if so can you check if removing it solves the issue?

Thanks.

@tomazfernandes
Copy link
Contributor

Closing due to inactivity. We can reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants