class Aws::Rails::EbsSqsActiveJobMiddleware

def execute_periodic_task(request)

def execute_periodic_task(request)
  # The beanstalk worker SQS Daemon will add the 'X-Aws-Sqsd-Taskname' for periodic tasks set in cron.yaml.
  job_name = request.headers['X-Aws-Sqsd-Taskname']
  @logger.debug("Creating and executing periodic task: #{job_name}")
  begin
    job = job_name.constantize.new
    job.perform_now
  rescue NoMethodError, NameError => e
    @logger.error("Periodic task #{job_name} could not resolve to an Active Job class - check the spelling in cron.yaml.")
    @logger.error("Error: #{e}.")
    return INTERNAL_ERROR_RESPONSE
  end
  [200, { 'Content-Type' => 'text/plain' }, ["Successfully ran periodic task #{job_name}."]]
end