1
votes

I'm trying to make a small example with wisper-sidekiq gem. The queue is created, but it does not start. Why? I will describe the steps that you are doing, I think it will be easier. I hope for your help.

A. controller:

class BooksController < ApplicationController
def create
    service = CreateBook.new
    service.subscribe(ActivityListener, async: true)
    service.on(:reserver_item_successfull) { |book| redirect_to book_path(book.id) }
    service.on(:reserver_item_failed)      { |book| @book = Book.new(book_params); respond_with(@book) }
    service.execute(current_user, book_params)
end

B. service:

require 'wisper/sidekiq'
require 'sidekiq/api'

class CreateBook
  include Wisper::Publisher

  def execute(performer, attributes)
    book = Book.new(attributes)
    if book.valid?
      book.save
      broadcast(:reserver_item_successfull, performer, book)
    else
      broadcast(:book_failed, performer, book)
    end
  end
end

C. listener:

class ActivityListener
  def self.reserver_item_successfull(performer, book)
    puts performer.name.to_s + ", book: " + book.title.to_s
  end
end

When I save the book, then of course creates a queue. But:

  • sidekiq silent (the logs are empty, but the queue was created)
  • redis silent too

Maybe I'm wrong start redis (redis-server) or sidekiq (bundle exec sidekiq)? Please help me.

P.S. Try bundle exec sidekiq -d -e production sidekiq -q default -C config/sidekiq.yml, but not result. The sidekiq.rb empty.

2
Next time you cross-post to both SO and the Issue Tracker can you include the link to each other so effort is not duplicated in answering your question.Kris
OK. Thanks for you help!user3118720

2 Answers

1
votes

I think you can get this fixed by the following steps:

  • require 'sidekiq/web' and then, mount Sidekiq::Web => '/sidekiq'
  • go to /sidekiq to see if there're workers/tasks/queues
  • if there aint
    • something may be wrong with your redis
    • or your code, put a binding.pry there
  • if there're, must be something wrong with your code, put a binding.pry there

Hope that helps :-)

1
votes

The problem is solved. I had to run sidekiq:

bundle exec sidekiq-r ./server.rb-L log/sidekiq.log also in server.rb

require 'sidekiq'

Sidekiq.configure_server do |config| config.redis = { url: 'redis://localhost:6379/0' } end

Sidekiq.configure_client do |config| config.redis = { url: 'redis://localhost:6379/0' } end