Reputation: 43
I have created SQS Queue and event source mapping that triggers lambda function on receiving message. All this works fine and I am doing through aws java sdk.
Now I want to return value from Lambda function. How will I be able to access it as I am calling Lambda function only through SQS.Any help is appreciated
Below is my handler method structure:
public String handleRequest(SQSEvent event, Context context) {
.....
....
return "something"
}
Upvotes: 2
Views: 3777
Reputation: 269390
This is not possible because the that sends a message to Amazon SQS completes once the message is sent. This allows the queue to be used to decouple services. In fact, a message could sit in an SQS queue for up to 14 days.
While the SQS queue will trigger the AWS Lambda function very quickly, there is still no concept of a "return" value from the Lambda function if it is triggered from an SQS message.
If you wish to trigger Lambda and wait for a response, you can directly invoke the Lambda function and await a response. This would not involve the use of SQS.
Upvotes: 0