I've got two AWS lambda functions connected together via an SQS queue. They've been working correctly for a while, but recently the size of the payload has increased and now it's broken the 256Kb limit.
After reading Question 43738341 like to use the AmazonSQSExtendedClient. I've looked at the code at github and have made my first lambda function send messages correctly (small payloads go via SQS, larger payloads are written to S3).
What I'm struggling with is receiving messages: The entry point for my second lambda looks like:
public class SqsHandler implements RequestHandler<SQSEvent, Void> {
public Void handleRequest(SQSEvent event, Context context) {
SQSEvent.SQSMessage record = event.getRecords().get(0);
System.out.println("0. record " + record.toString());
System.out.println("1. eventSource " + record.getEventSource());
System.out.println("2. eventSourceARN " + record.getEventSourceArn());
System.out.println("3. MessageId" + record.getMessageId());
System.out.println("4. ReceiptHandle " + record.getReceiptHandle());
System.out.println("5. Body " + record.getBody());
}
}
When my entry point is called I've already received my SQS event. I don't (and shouldn't?) know the queue it's come from.
The code sample on GitHub (which is copied almost line by line onto all of the other sites) the sender and receiver are both the same lambda. Consequently it's able to create a ReceiveMessageRequest object because it knows the queue URL.
In a real system the sender and receiver are never the same. I could even be receiving data from multiple Lambdas over multiple queues
What I don't understand is how the receiving Lambda should be written. The sample code on the AWS Website says:
final ReceiveMessageRequest receiveMessageRequest =
new ReceiveMessageRequest(myQueueUrl);
List<Message> messages = sqsExtended
.receiveMessage(receiveMessageRequest).getMessages();
But this requires me to know the url of the queue. It also doesn't tie into the SQSEvent, which will need to be consumed.