AWS Lambda के साथ Serverless Applications
Claudio Canales
Senior DevOps Engineer


Push मॉडल
Poll मॉडल

Queue (Amazon SQS)
Stream (DynamoDB Streams)

{
"Records": [{
"messageId": "abc-123",
"body": "{\"order_id\": \"A-42\"}"
}]
}
Records से शुरू होते हैं।messageId और body string होती है।body पार्स करके अपना payload बनाइए।def lambda_handler(event, context):
records = event.get("Records", [])
for record in records:
body = record.get("body", "")
print("BODY:", body)
return {"statusCode": 200}
Records को डिफ़ॉल्ट लिस्ट के साथ पढ़ें।body सुरक्षित रूप से पढ़ें।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 इम्पोर्ट करें और body को सुरक्षित डिफ़ॉल्ट से पढ़ें।json.loads से पार्स करके dict पाएँ।ApproximateAgeOfOldestMessage मॉनिटर करें।




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 को batchItemFailures में इकट्ठा करें।
AWS Lambda के साथ Serverless Applications