AWS Lambda ile Sunucusuz Uygulamalar
Claudio Canales
Senior DevOps Engineer


İtme modeli
Yoklama modeli

Kuyruk (Amazon SQS)
Akış (DynamoDB Streams)

{
"Records": [{
"messageId": "abc-123",
"body": "{\"order_id\": \"A-42\"}"
}]
}
Records ile başlar.messageId ve body dizesi vardır.body'yi kendi yükünüze ayrıştırın.def lambda_handler(event, context):
records = event.get("Records", [])
for record in records:
body = record.get("body", "")
print("BODY:", body)
return {"statusCode": 200}
Records'u okuyun.body'yi güvenli okuyun.import json
def lambda_handler(event, context):
record = event.get("Records", [])[0]
payload = json.loads(record.get("body", "{}"))
order_id = payload.get("order_id")
print("ORDER_ID:", order_id)
return {"statusCode": 200}
json içe aktarın ve body'yi güvenli varsayılanla okuyun.json.loads ile ayrıştırıp bir dict alın.ApproximateAgeOfOldestMessage'ı izleyin.




def lambda_handler(event, context):
failures = []
for record in event.get("Records", []):
try:
process(record)
except Exception:
failures.append({"itemIdentifier": record["messageId"]})
return {"batchItemFailures": failures}
messageId'lerini batchItemFailures içinde toplayın.
AWS Lambda ile Sunucusuz Uygulamalar