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

SqsTemplate receiving messages but @SQSListener not on Spring Boot 3.1.5 #926

Closed
jsierra-dyna opened this issue Oct 27, 2023 · 3 comments
Closed
Labels
component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer

Comments

@jsierra-dyna
Copy link

jsierra-dyna commented Oct 27, 2023

Type: Bug

Component: SQS

Describe the bug
When using Spring Boot 3.1.5 alongside spring-cloud-aws-starter-sqs 3.0.2 and Spring Cloud 2022.0.4, I can pull messages from SQS using SqsTemplate, but not passively receive them when applying @SQSListener to a groovy 4.0.15 method

Sample
------Bean configs--------

@Configuration(proxyBeanMethods = false)
@Slf4j
class Config{
    @Bean
    @Primary
    SqsAsyncClient sqsAsyncClient() {
        return SqsAsyncClient
                .builder()
                .credentialsProvider(DefaultCredentialsProvider.create())
                .region(Region.of("us-east-1"))
                .build()
    }

    @Bean
    SqsMessageListenerContainerFactory<Object> defaultSqsListenerContainerFactory(SqsAsyncClient sqsAsyncClient) {
        return SqsMessageListenerContainerFactory
                .builder()
                .sqsAsyncClient(sqsAsyncClient)
                .configure {
                    it
                            .acknowledgementMode(AcknowledgementMode.ON_SUCCESS)
                }
                .build()
    }

    @Bean
    SqsAsyncOperations template(SqsAsyncClient sqsAsyncClient) {
        return SqsTemplate.newAsyncTemplate(sqsAsyncClient)
    }
}

------ListenedMethod-------

@Component
@RefreshScope
class QueueListener {
    @SqsListener(queueNames = ['queueName'])
    void receiveMessage(MyPojo message) {
        log.info("message from queue: $message")
    }
}

------Working sqsTemplate Usage-------

@RestController
class TestController {

    @Autowired
    SqsAsyncOperations template

    @GetMapping(path = "/test")
    ResponseEntity pull() {
        Optional<Message<MyPojo>> result = template.receiveAsync("queueName", MyPojo).get()
        return ResponseEntity.ok(result)
    }
}

Thanks beforehand!

@maciejwalkowiak
Copy link
Contributor

@jsierra-dyna can you publish complete project that reproduces this problem? It may be a version problem, configuration problem, Groovy problem and I don't think i'll come up with exactly the same setup as yours

@maciejwalkowiak maciejwalkowiak added component: sqs SQS integration related issue status: waiting-for-feedback Waiting for feedback from issuer labels Oct 27, 2023
@jsierra-dyna
Copy link
Author

@maciejwalkowiak Thank you for your prompt answer!

You can see a project that reproduces what is described here.

https://github.com/jsierra-dyna/TestListener

Thanks again!

@jsierra-dyna
Copy link
Author

Upon further inspection, this was a problem caused by a misconfiguration on my side, so I am closing this issue.

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 status: waiting-for-feedback Waiting for feedback from issuer
Projects
None yet
Development

No branches or pull requests

2 participants