awspring / spring-cloud-aws

The New Home for Spring Cloud AWS
http://awspring.io
Apache License 2.0
883 stars 301 forks source link

spring boot native image is not able to read message from AWS SQS #1021

Open pulsar-gupta opened 10 months ago

pulsar-gupta commented 10 months ago

Type: Bug

Component: SQS

Describe the bug

I have an application and it reads messages from sqs when run locally but as soon as I deploy it's native image on EKS nothing happens and messages are queued on SQS. It looks as is my native image is not reading messages from SQS. No logs are printed and no exception.

Here is my code:

@Configuration public class ReaderConfiguration {

@Bean
public SqsClient sqsClient() {
    try {       
        AwsBasicCredentials credentials = AwsBasicCredentials.create("access-key", "secret");
        return SqsClient.builder().region(Region.of("eu-central-1")).credentialsProvider(() -> credentials).build();
    } catch (Exception e) {
        e.printStackTrace();
        throw new AwsAuthenticationError("Aws Authentication Error");
    }
}

} @Component public class SQSListner {

private SqsClient sqsClient = null;

@Autowired
public SQSListner(SqsClient sqsClient) {
    this.sqsClient = sqsClient;
}

@SqsListener("notification")
public void recieveMessage(Message msg) {
    System.out.println("Received Message" + msg.body());
    // processMsg();
}

}

io.awspring.cloud spring-cloud-aws-starter-sqs org.springframework.boot spring-boot-starter-parent 3.0.0

image is build using mvn -Pnative spring-boot:build-image

MatejNedic commented 9 months ago

Hey @pulsar-gupta , we have open PR for this it is known issue.

pulsar-gupta commented 9 months ago

with some changes I was able to resolve the issue first step was to upgrade the spring boot and spring cloud version

  1. io.awspring.cloud - spring-cloud-aws-dependencies - 3.1.o
  2. software.amazon.awssdk - bom - 2.20.45
  3. spring-boot - 3.2.1

second step was to register hints

and created image mvn -Pnative spring-boot:build-image

Now works absolutely fine