Skip to content

Instantly share code, notes, and snippets.

@civic
Created January 22, 2023 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save civic/7b0f482b15fac8bcda4c3f08a26d3a43 to your computer and use it in GitHub Desktop.
Save civic/7b0f482b15fac8bcda4c3f08a26d3a43 to your computer and use it in GitHub Desktop.
consumer.py
import logging
import json
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
def lambda_handler(event, context):
for record in event['Records']:
message_id = record['messageId']
attributes = record['attributes']
approximateReceiveCount = attributes['ApproximateReceiveCount']
body = record['body']
msg = json.loads(body)
log.info("Consumed a message: no=[%s], messageId=[%s], ApproximateReceiveCount=[%s]",
msg['no'], message_id, approximateReceiveCount)
log.info("Finish %d records", len(event['Records']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment