package com.example.aws.Springbootsqs.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate;
import org.springframework.cloud.aws.messaging.listener.annotation.SqsListener;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SQSController {
Logger logger =LoggerFactory.getLogger(SQSController.class);
@Autowired
private QueueMessagingTemplate queueMessagingTemplate;
@Value("${cloud.aws.end-point.uri}")
private String endPoint;
@GetMapping("/put/{msg}")
public void putMessagesToQueue(@PathVariable("msg") String message) {
queueMessagingTemplate
.send(endPoint, MessageBuilder
.withPayload(message)
.build());
}
@SqsListener("sqs-queue")
public void loadMessagesFromQueue(String message) {
logger.info(message);
}
}
I am okay with pushing the messages to SQS but at the same time when i am reading and printing the messages the method is not being called and it is not printing anything from SQS and no error on console.
Any help will be useful. Thanks in advance.