Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud - SQS

I'm trying to get a simple queue handler working with the Spring Cloud framework. I've successfully got the message handler polling the queue, However. The problem I'm seeing is that when I post a message to the queue, my handler is failing to unmarshall the payload in to the required java Object.

@MessageMapping("MyMessageQueue")
@SuppressWarnings("UnusedDeclaration")
public void handleCreateListingMessage(@Headers Map<String, String> headers, MyMessage message) {
    //do something with the MyMessage object
}

The error I'm getting is

No converter found to convert to class MyMessage

As I understand it, the @MessageMapping should use Jackson to unmarshall my JSON payload into a MyMessage object. However its complaining that it cannot find a converter.

Has anyone come across this?

I'm using the 1.0.0.BUILD-SNAPSHOT version of Spring Cloud.

like image 831
Slihp Avatar asked Dec 31 '14 16:12

Slihp


1 Answers

Jackson is only used if a contentType header is set with value application/json on the SQS message. Otherwise the converters do not know what type of content is contained in the message's payload and the right converter cannot be chosen.

If you use QueueMessagingTemplate#convertAndSend as in the reference application, the contentType header will automatically be set.

like image 192
Alain Avatar answered Nov 10 '22 13:11

Alain