delayed-job

What's the best way to test delayed_job chains with rSpec?

£可爱£侵袭症+ 提交于 2019-12-21 03:45:14
问题 Currently when I have a delayed method in my code like the following: CommentMailer.delay.deliver_comments(@comment, true) I write something like this in my spec: dj = mock("DelayProxy") CommentMailer.should_receive(:delay).and_return(dj) dj.should_receive(:deliver_comments).with(comment, true) Is there a better way to handle this and/or chained methods like that in rSpec in general? 回答1: We can just have one more line in the before block as following: CommentMailer.stub(:delay).and_return

How do I separate workers into pools of jobs with delayed job + heroku?

此生再无相见时 提交于 2019-12-21 02:42:09
问题 My environment is rails 3.1, heroku bamboo stack, delayed_job_active_record, (https://github.com/collectiveidea/delayed_job ) and experimenting with hirefire. (https://github.com/meskyanichi/hirefire) - I can see the delayed_job queue documentation, but how do I apply this on heroku? I have a max priority set of tasks that get spawned off every hour that I need to dedicate 3 workers to, it takes approx 26 minutes to complete. During that time, less important background tasks need to continue,

What's the most elegant way to implement a digest email without reinventing a queueing system?

拈花ヽ惹草 提交于 2019-12-20 14:17:05
问题 I have my transactional email system setup & by default people get emails as events happen: class Comment after_create :email_original_poster def email_original_poster UserMailer.delay.notify_author_of_comment self end end However instead of getting the email as-it-happens, a chunk of my users would prefer a daily or weekly digest. What's the cleanest most elegant way to implement this? I've already got delayed_job running but this doesn't really feel like a delayed_job job since I'm queueing

What's the most elegant way to implement a digest email without reinventing a queueing system?

天大地大妈咪最大 提交于 2019-12-20 14:16:28
问题 I have my transactional email system setup & by default people get emails as events happen: class Comment after_create :email_original_poster def email_original_poster UserMailer.delay.notify_author_of_comment self end end However instead of getting the email as-it-happens, a chunk of my users would prefer a daily or weekly digest. What's the cleanest most elegant way to implement this? I've already got delayed_job running but this doesn't really feel like a delayed_job job since I'm queueing

Is Rails's “delayed_job” for cron task really?

早过忘川 提交于 2019-12-20 10:43:12
问题 delayed_job is at http://github.com/collectiveidea/delayed_job Can delayed_job have the ability to do cron task? Such as running a script every night at 1am. Or run a script every 1 hour. If not, what are the suitable gems that can do that? And can it be monitored remotely using a browser, and have logging of success and error? 回答1: I worked on a project that tried to use DelayedJob to schedule future items. It sucked. Instead I recommend you use the whenever gem: http://github.com/javan

Running delayed jobs on Heroku for free

荒凉一梦 提交于 2019-12-20 09:55:10
问题 Is it possible to run delayed jobs on Heroku for free? I'm trying to use delayed_job_active_record on Heroku. However, it requires a worker dyno and it would cost money if I turned this dyno on for full time. I thought using Unicorn and making its workers run delayed jobs instead of the Heroku worker, would cost nothing, while successfully running all the jobs. However, Unicorn workers do not seem to start "working" automatically. I have the following in my Procfile . web: bundle exec unicorn

Rails/Rspec: Testing delayed_job mails

谁说我不能喝 提交于 2019-12-20 09:35:21
问题 Just wondering how to test that actionmailer requests are actually sent to the delayed_job que in rspec. I would have assumed it was quite simple, but my delayed_job queue doesn't seem to be incrementing. Code below: Controller: def create @contact = Contact.new(params[:contact]) if @contact.save contactmailer = ContactMailer contactmailer.delay.contact_message(@contact) redirect_to(contacts_url) else render :action => "new" end Spec: it "queues mail when a contact is created" do

Delayed Job Rake Task Failing

若如初见. 提交于 2019-12-20 03:11:26
问题 I'm trying to get delayed job to work as a rake task, but for the life of me I can't figure out what I'm doing wrong. Given the following setup: #config/environment.rb Rails::Initializer.run do |config| config.gem 'delayed_job' end #Rakefile begin require 'delayed/tasks' rescue LoadError STDERR.puts "Run `rake gems:install` to install delayed_job" end #Observer class SomeObserver < ActiveRecord::Observer def foo(bar) end handle_asynchronously :foo end Whenever I run rake jobs:clear I get the

Undefined Method Error when creating delayed_job workers with script/delay_job

余生颓废 提交于 2019-12-19 10:28:15
问题 Having a bit of a problem running multiple workers. When creating workers with rake jobs:work jobs run without and problem, even when invoking it multiple times, but when creating workers with ruby script/delayed_job -n 5 start all jobs fail with undefined method on Syck::DomainType . I've searched quite a bit, but can't seem to find the solution for this. I am running DelayedJob on the Mongoid backend. Gem versions: rake 0.9.2 rails 3.0.6 delayedjob 2.1.4 delayedjob_mongoid 1.0.2 Has anyone

Use Delayed::Job to manage multiple job queues

最后都变了- 提交于 2019-12-18 22:29:26
问题 I want to use Delayed::Job (or perhaps a more appropriate job queue to my problem) to dispatch jobs to multiple background daemons. I have several background daemons that carry out different responsibilities. Each one is interested in different jobs in the queue from the Rails app. Is this possible using Delayed::Job, or perhaps there is a different job queue that better fits this task? 回答1: Since then http://github.com/collectiveidea/delayed_job has reached v3.0 and includes named queues!