Jets Job Enabling

To enable Jets Job you configure 2 things:

  1. Jets SQS Queue and Lambda Worker: config.job.enable = true
  2. Jets Job ActiveJob Adapter: config.active_job.queue_adapter = :jets_job

Jets SQS Queue and Lambda Worker

A SQS Queue and Job Processor (Lambda) is created upon jets deployment.

To enable the creationg of Jets Job resources to handle ActiveJob work:


Jets.deploy.configure do
  config.job.enable = true

This creates:

  1. The SQS Queue to store the jobs
  2. The Lambda Function that listens to Queue events and processes the jobs

AWS Lambda scales automatically to process the queue.

Jets Job ActiveJob Adapter

Jets provides a jets_job ActiveJob adapter that queues jobs to SQS. To enable it:


Rails.application.configure do
  config.active_job.queue_adapter = :jets_job

Example Job

Here’s an example job


class CleanupJob < ApplicationJob
  def perform(*args)
    puts "Cleaning up: #{args}"

Jets Deploy

That gives you enough to deploy.

jets deploy

When you deploy a Jets app, it’ll create an SQS Queue and a jets-queue_event-handle Lambda function to handle the Jets jobs processing. It looks something like this:

Test Jets Job SQS Queue

To test the Jets Job and confirm it’s using the SQS queue, you can either use RAILS_ENV=production rails console or also configure your Rails development.rb settings to use the :jets_job adapter also. Example:


Rails.application.configure do
  config.active_job.queue_adapter = :jets_job

When you call the job, it will send it to the deployed SQS queue.

$ rails console
> CleanupJob.perform_later("desk")

It gets added to the SQS Queue and immediately processed by the Lambda function. You can see the work being process via the logs.

$ jets logs -f -n jets-queue_event-handle
Cleaning up: desk

Tip: If you need to remember the Lambda function name, you can use the jets functions command to find it.

Jets Job IAM

When config.job.enable = true, Jets will automatically adds the necessary SQS IAM permission so that your Lambda functions can send messages to the SQS queue that Jets creates as part of deployment.


The table below covers each setting. Each option is configured with config.OPTION. The config. portion is not shown for conciseness. IE: logger.level vs config.logger.level.

Name Default Description
job.additional_queues [] Example: %w[urgent low_priority]
job.default_queue.lambda.reserved_concurrency 5 Reserved concurrency to use for Lambda function associated with default queue. {} Override the SQS Queue properties. See Generated Function SQS Queue and AWS::SQS::Queue.
job.enable false Enable Jets to create Job resources to handle ActiveJob work, like SQS Queue.
job.queue_defaults.lambda.memory_size 1536 Default reserved concurrency for memory_size lambda functions. Can be overwritten individually with config.job.queues.NAME.lambda.memory_size {} Default properties for the additional_queues lambda functions. Can be overwritten individually with config.job.queues.NAME.lambda.PROPERTY
job.queue_defaults.lambda.reserved_concurrency 5 Default reserved concurrency for additional_queues lambda functions. Can be overwritten individually with config.job.queues.NAME.lambda.reserved_concurrency
job.queue_defaults.lambda.timeout 900 Default timeout for additional_queues lambda functions. Can be overwritten individually with config.job.queues.NAME.lambda.timeout {} Default properties for the additional_queues. Can be overwritten individually with config.job.queues.NAME.PROPERTY. See AWS::SQS::Queue
job.queues.NAME.memory_size 1536 An example of how you can set individual additional queue the memory_size setting.
job.queues.NAME.reserved_concurrency 5 An example of how you can set individual additional queue the reserved_concurrency setting.

See Full Config Reference