Skip to content
Pablo Cantero edited this page Jul 1, 2017 · 4 revisions

Plain Ruby

Create a worker

class HelloWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'hello', auto_delete: true

  def perform(sqs_msg, name)
    puts "Hello, #{name}"
  end
end

Create a queue

bundle exec shoryuken sqs create hello

Start Shoryuken

bundle exec shoryuken -q hello -r ./hello_worker.rb

Enqueue a message

HelloWorker.perform_async('Ken')

Rails

Create a job

# app/jobs/hello_job.rb
class HelloJob < ActiveJob::Base
  queue_as 'hello'

  def perform(name)
    puts "Hello, #{name}"
  end
end

Create a queue

bundle exec shoryuken sqs create hello

Set the queue backend

# config/application.rb
module YourApp
  class Application < Rails::Application
    config.active_job.queue_adapter = :shoryuken
  end
end

Start Shoryuken

bundle exec shoryuken -q hello -R

Enqueue a message

HelloJob.perform_later('Ken')