rails-activejob

ActiveJob with Resque: enqueuing jobs with uninteded arguments

六眼飞鱼酱① 提交于 2019-12-23 16:52:46
问题 Trying to implement some kind of cancel job functionality. In order to destroy a job with Resque, one needs the specific arguments passed to it. It appears I'm passing in unintended information by mistake though. I'm expecting just the arguments value to be within the outside brackets. I'm creating the job like so: PhysicalServerProvisionJob.perform_later('123') I'd like to be able to: Resque::Job.destroy(:default, PhysicalServerProvisionJob, '123') However this isn't possible due to the

How can I run an ActiveJob in Rails console for debugging?

天涯浪子 提交于 2019-12-23 08:49:39
问题 I currently have an ActiveJob that I've created and use Sidekiq to queue it. I'm wanting to debug the job, but for me to see any messages I program into it I have to check my log files. I feel like it would be more convenient to be able to see my puts messages in my job in the Rails Console. When I run the perform_later method though in rails console it just queues the job up and I never see the messages in console. Is there a way to make it where I will see them in the console? 回答1: You can

rspec rails testing: how can I force ActiveJob job's to run inline for certain tests?

喜你入骨 提交于 2019-12-23 08:06:34
问题 I would like my background jobs to run inline for certain marked tests. I can do it by wrapping the test with perform_enqueued do but I'd like to just be able to tag them with metadata and it happens automatically, if possible. I've tried the following: it "does everything in the job too", perform_enqueued: true do end config.around(:each) do |example| if example.metadata[:perform_enqueued] perform_enqueued_jobs do example.run end end end but it results in an error: undefined method `perform

Rails - ActionDispatch::Http::UploadedFile in background job

余生长醉 提交于 2019-12-23 07:47:57
问题 I'm using a similar idea as in the importing csv and excel Railscast but as the standard code in that episode takes some time to process (uses ActiveRecord to create a new record for each row in the file) I'm getting timeouts on Heroku and would like to move the import process to a background job. I have been unsuccessful at sending the file variable (which is of type ActionDispatch::Http::UploadedFile) to the job so instead I sent individual variables of the file.original_filename and file

Sidekiq Rails 4.2 Use Active Job or Worker? What's the difference

怎甘沉沦 提交于 2019-12-20 08:40:58
问题 This is my first processing jobs asynchronously I am implementing Sidekiq for background processing in my app. I will use it for reminder emails and in-app notifications. I am confused as to whether I should use Active Job to create a job that sends an email or a Sidekiq Worker to send an email. They seem to do the same thing and Rails 4.2 Active Job seems very new…is it replacing the need for a Sidekiq Worker? Below is the same sending a mailer code using an Active Job job and a Sidekiq

Sidekiq not finding records for Rails Active Job

匆匆过客 提交于 2019-12-11 16:12:11
问题 Jobs are queued on after a user is created like so in the model user.rb after_create_commit :profile_photo_job def profile_photo_job message = "Add a profile photo" ReminderJob.set(wait: 1800).perform_later(self.id.to_s, message) end reminder_job.rb class ReminderJob < ApplicationJob queue_as :default def perform(user_id, message) if user_id user = User.find(user_id) end ##sending message notification here end end However, it often throws the following error inside my sidekiq console

create recurring activejob fails

帅比萌擦擦* 提交于 2019-12-11 02:07:32
问题 I'm trying to create an ActiveJob in rails 4.2 that runs at a regular rate. The job is being called the first time, but it does not start again. My code is throwing the exception below after trying to call perform_later. log output [ActiveJob] Enqueued ProcessInboxJob (Job ID: 76a63689-e330-47a1-af92-8e4838b508ae) to Inline(default) [ActiveJob] [ProcessInboxJob] [76a63689-e330-47a1-af92-8e4838b508ae] Performing ProcessInboxJob from Inline(default) ProcessInboxJob running... [ActiveJob]

Rails ActiveJob - What's the good way to handle exception in ActionMailer::DeliveryJob

 ̄綄美尐妖づ 提交于 2019-12-10 16:38:11
问题 I am using ActiveJob + Sidekiq in my Rails project for task processing. I send my mails directly using MyMailer.some.deliver_later . It will automatically creates a ActionMailer::DeliveryJob task and put it in the Sidekiq queue. The question is, what's the good to handle exceptions from there? Best Regards. 回答1: According to http://edgeguides.rubyonrails.org/active_job_basics.html, I think the good way is to setup exception error handlers for ActionMailer::DeliveryJob in an initializer,

Using Sidekiq for Active Job and getting ActiveJob::DeserializationError

别说谁变了你拦得住时间么 提交于 2019-12-10 14:21:42
问题 I'm trying to use Sidekiq to run the below job. The job performs fine when not queued (perform_now) but fails when called as (perform_later), which uses Sidekiq. AddEmployeesToRoomJob.perform_now room ## works fine AddEmployeesToRoomJob.perform_later room ## breaks in Sidekiq Error: AddEmployeesToRoomJob JID-da24b13f405b1ece1212bbd5 INFO: fail: 0.003 sec 2016-08-20T14:57:16.645Z 19456 TID-owmym5fbk WARN: {"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped" :

MonkeyPatching ActiveJobs

泄露秘密 提交于 2019-12-09 18:58:19
问题 I am having an issue monkey-patching part of ActiveJobs. I have the following code in config/initializers/extensions/arguements.rb module ActiveJob module Arguments TYPE_WHITELIST = [ Date, DateTime, Time, NilClass, Fixnum, Float, String, TrueClass, FalseClass, Bignum ] end end Basically, I am trying to add basic support for Date/Time objects for use in the ActiveJob created by ActionMailer#deliver_later Upon loading the rails app I can see my whitelist is loaded, however when I call the