module Aws::Rails::SqsActiveJob
def self.lambda_job_handler(event:, context:)
Configure the entrypoint to: +config/environment.Aws::Rails::SqsActiveJob.lambda_job_handler+
Trigger the lambda from your SQS queue
A lambda event handler to run jobs from an SQS queue trigger
def self.lambda_job_handler(event:, context:) return 'no records to process' unless event['Records'] event['Records'].each do |record| sqs_msg = to_sqs_msg(record) job = Aws::Rails::SqsActiveJob::JobRunner.new(sqs_msg) puts("Running job: #{job.id}[#{job.class_name}]") job.run sqs_msg.delete end "Processed #{event['Records'].length} jobs." end