0

I have a lambda function which is implemented with Chalice and I am trying to process SQS messages with it.

The code is implemented based on this documentation: https://aws.github.io/chalice/api.html#Chalice.on_sqs_message

app.py

app = Chalice(app_name='payment-service')

@app.on_sqs_message(queue="payment-service-dev.fifo")
def lambda_sqs_message(event):
    print("MESAGE QUEUE EVENT ", event)
    for record in event:
      print("Process Event")
    return True

The problem is that I am not receiving any logs from the lambda_sqs_message when the Lambda Function handler is set to app.app. However, it works if I set the Lambda Function handler to app.lambda_sqs_message.

Handler set to app.app - Queue events not processed enter image description here

Handler set to app.lambda_sqs_message - Queue events are processed enter image description here

I don't think that it makes any sense to have the the Lambda handler set to lambda_sqs_message because this way the on_sqs_message is useless.

Did I misunderstood the configuration requirements and the Lambda Function handler needs to be set to the SQS message handler function, instead of the Chalice instance?

Valip
  • 4,440
  • 19
  • 79
  • 150
  • So you mean with decorator `@app.lambda_sqs_message` it works but `app.on_sqs_message` does not work – Bao Tran Oct 31 '22 at 09:40
  • It's working only if I configure the Lambda Function to have the handler set to `app.on_sqs_message` and I don't understand why it's not working while it's set to `app,app` – Valip Oct 31 '22 at 12:26
  • could you give 2 versions of code (1 work and 1 does not), that would be useful – Bao Tran Nov 01 '22 at 03:37

0 Answers0