[Backgroundrb-devel] Persistent queue and scheduled jobs
csarva at operative.com
Thu Sep 25 13:53:47 EDT 2008
Note that my patch below was for the case where you have a single,
simple argument like a string or int, as it is in our case. If an
array or hash is passed, I'm not sure what the behaviour would be.
On Sep 24, 2008, at 1:05 PM, hemant wrote:
> Thanks, Chetan for the patch, I will be commiting them soonish.
> On Wed, Sep 24, 2008 at 5:05 AM, Chetan Sarva <csarva at operative.com>
>> While playing with scheduled jobs, I ran into a couple of issues
>> and made a
>> few notes.
>> 1) Times MUST be UTC:
>> I've got the following:
>> BdrbJobQueue.insert_job(:worker_name => 'backup_worker',
>> :worker_method => 'do_work',
>> :args => @backup.id,
>> :scheduled_at => Time.now + 30)
>> resulting in:
>> submitted_at: 2008-09-23 17:57:26
>> started_at: 2008-09-23 17:57:30
>> finished_at: NULL
>> archived_at: NULL
>> scheduled_at: 2008-09-23 17:57:56
>> changing it to Time.now.utc + 30 fixes it.
>> 2. job_key is mandatory when using the persistent queue since there
>> is a
>> unique key check on this field. This was not immediately obvious,
>> and no key
>> is automatically generated. The above code inserts NULL for job_key.
>> I can submit doc patches for the above if that helps.
>> 3. When firing the job at the scheduled time, MetaWorker calls
>> Marshal.load() on `args` though they were not previously marshalled
>> ActiveRecord. I made the following change in my WC in order to move
>> this problem:
>> Index: vendor/plugins/backgroundrb/server/lib/meta_worker.rb
>> --- vendor/plugins/backgroundrb/server/lib/meta_worker.rb
>> +++ vendor/plugins/backgroundrb/server/lib/meta_worker.rb
>> @@ -287,10 +287,9 @@
>> Thread.current[:persistent_job_id] = task[:id]
>> Thread.current[:job_key] = task[:job_key]
>> called_method_arity = self.method(task.worker_method).arity
>> - args = load_data(task.args)
>> if called_method_arity != 0
>> - self.send(task.worker_method,args)
>> + self.send(task.worker_method,task.args)
>> Backgroundrb-devel mailing list
>> Backgroundrb-devel at rubyforge.org
> Let them talk of their oriental summer climes of everlasting
> conservatories; give me the privilege of making my own summer with my
> own coals.
More information about the Backgroundrb-devel