Having issues with calling/finding consumer
chernesk opened this issue · 3 comments
I'm probably going about this all wrong, but would really appreciate some help.
I have a job in app/jobs/award_print_job.rb
that looks like:
class AwardPrintJob < ActiveJob::Base
queue_as :award_print
def perform(metadata)
....
end
end
and things get queued into Rabbit just fine.
I'm having a problem with having a consumer found. I have in app/consumers/award_print_consumer.rb
class AwardPrintConsumer
include Sneakers::Worker
from_queue :award_print (and I've tried 'award_print'
def work(msg)
...
ack!
end
end
And nothing gets pulled off the queue and work is not called.
I'm sure that there's something silly that I'm doing wrong. Could you help point me in the right direction?
Thanks!
Hey @chernesk
The purpose of this library is to use the Sneakers as an adapter. If you have an ActiveJob class defined, you don't need to have a dedicated Sneakers consumer. The gem does it for you.
Just make sure you have the correct ActiveJob adapter activated for the environment and start the worker.
# config/initializers/development.rb and production.rb
config.active_job.queue_adapter = :advanced_sneakers
rake sneakers:active_job
Thank you very much for your reply.
I totally get what you're saying, and I expected it to work that way, even though I didn't communicate it that well in the first comment.
What I wanted to convey was that this was the second way that I had tried. The first way was:
class AwardPrintJob < ActiveJob::Base
queue_as :award_print
def perform(metadata)
.....
end
end
And perform never gets called when I start it as you suggest above: rake sneakers:active_job
I guess I'll keep on trying to figure out what I'm doing wrong. For whatever reason, it enqueues the job, but never processes it.
Thank you for confirming that it should be working that way. It's probably something weird in my environment.
@chernesk I suggest to start the worker process exclusively for the queue
QUEUES=award_print rake sneakers:active_job
If the worker boots correctly you will be able to see its AMQP connection entry on the consumers tab of the queue in RabbitMQ management UI.