Question: Dequeue active job with Active job in Rails

Question

Dequeue active job with Active job in Rails

Answers 1
Added at 2016-10-12 12:10
Tags
Question

I could enqueue jobs with perform_later but it's not dequeued at all. Also I set WelcomeEmailJob.set(wait: 1.seconds) It's not launched.

tail -f log/development.log

[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 7df3d8a5-8eaa-4cbe-b419-83f0326b5376) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 29100edd-9896-4acb-b16b-4695e7be5757) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: fa57ef26-7134-442a-9bde-858fa487f5d4) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: d645e315-28ad-43ce-9426-e4a338d52bdc) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 12b89c71-96c6-4ad5-a655-f0d301d10543) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: f9d60fd0-9633-4b65-80f8-c0d5bdbc473b) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 4385647c-bfc2-425e-894f-000d0ccb2095) to Sidekiq(default)
[ActiveJob] Enqueued WelcomeEmailJob (Job ID: 87624fe0-44ea-4eb9-a97e-fcada60a9354) to Sidekiq(default)

How should I dequeue jobs and see the list?

class WelcomeEmailJob < ActiveJob::Base
  queue_as :default

  def perform
    # Do something later
    logger.warn  "TEST WARNING"
  end
end

docker-compose.rb

services:
  web:
    depends_on:
      - 'postgres'
      - 'redis'
    build: .
    command: rails server -b 0.0.0.0
    ports:
      - '3000:3000'
    volumes:
      - '.:/usr/src/app'
    env_file:
      - '.env'

  postgres:
    image: 'postgres:9.4.4'
    environment:
      POSTGRES_USER: 'postgres'
    ports:
      - '5432:5432'

  redis:
    image: 'redis:3.2-alpine'
    command: redis-server --requirepass yourpassword
    ports:
      - '6379:6379'

  sidekiq:
    depends_on:
      - 'postgres'
      - 'redis'
    build: .
    command: bundle exec sidekiq -C config/sidekiq.yml.erb
    volumes:
      - '.:/usr/src/app'
    env_file:
      - '.env'

UPDATE

config/initializers/sidekiq.rb

sidekiq_config = { url: 'redis://127.0.0.1:6379' }

Sidekiq.configure_server do |config|
    config.redis = sidekiq_config
end

Sidekiq.configure_client do |config|
    config.redis = sidekiq_config
end
Answers to

Dequeue active job with Active job in Rails

nr: #1 dodano: 2016-10-12 13:10

You should run the sidekiq worker. bundle exec sidekiq

Source Show
◀ Wstecz