Spring Cloud - SQS

I am trying to get a simple queue handler working with a Spring Cloud scope. However, I successfully received a message handler that polled the queue. The problem that I see is that when I send a message to the queue, my handler cannot unload the payload into 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 get is

 No converter found to convert to class MyMessage 

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

Has anyone come across this?

I am using version 1.0.0.BUILD-SNAPSHOT Spring Cloud.

+7
java spring spring-cloud amazon-web-services amazon-sqs
source share
1 answer

Jackson is used only if the contentType header contentType set with the application/json value in the SQS message. Otherwise, the transformers do not know what type of content is contained in the message payload, and the right transformer cannot be selected.

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

+11
source share

All Articles