0

I am trying to intgerate AWS sqs and AWS lambda. I am using spring cloud function for implementing the lambda. The lambda is configured with a trigger for SQS queue.

Versions used spring-cloud.version 2022.0.3 Java 17 spring-cloud-aws-dependencies 3.0.1

I am using the below handler for invoking my function.

org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest

Below is the bean for reading the message

@Bean
public Function<Message<String>, String> recMsg() {
    return v -> {
        System.out.println(v.getPayload());
        System.out.println(v.getHeaders());
        return v.getPayload();
    };
}

I see the code is working fine . However the function is called only once for each message. As per my understanding the aws should be able to call the function with a batch of messages.

I see something wrong with my implementation.

Kindly direct me to any documentation which suggests to use a better approach.

  • This is definitely not a question for s-c-function. That said, what makes you believe that it should deal with batch? Especially in the context of your function signature as it its talking a single argument of type Message rather some type of collection. – Oleg Zhurakousky Jun 12 '23 at 08:51
  • @OlegZhurakousky Thanks for your reponse. I am trying to use spring cloud function with AWS lambda. if s-c-function is not the candidate what will you suggest to use with aws lambda from spring. i thought s-c-function is the primary candidate to go with AWS lambda. – user1979788 Jun 12 '23 at 10:15
  • Actually i am trying to find the equivalent in spring cloud function using the below example. [link] (https://github.com/awsdocs/aws-lambda-developer-guide/blob/main/sample-apps/java-events/src/main/java/example/HandlerSQS.java) – user1979788 Jun 12 '23 at 12:48
  • Your example takes a single `SQSEvent event` so I am still not following with regard to batch – Oleg Zhurakousky Jun 12 '23 at 18:17

0 Answers0