[Backgroundrb-devel] State of backgroundrb (dupe?)

Morten Primdahl primdahl at mac.com
Fri Mar 21 16:49:30 EDT 2008


On Mar 21, 2008, at 9:28 PM, Kit Plummer wrote:
> I too have been fine with the 1.0.3 stuff.  New dependencies...but, no
> big deal.
>
> I'm curious though...what else is there?  If you were to go looking
> what would you find?

Then I'd be looking for a queuing mechanism of sorts, inspiration here:
http://nubyonrails.com/articles/about-this-blog-beanstalk-messaging-queue

And a question, the API has changed some since the version I use, and  
I have a little problems getting my most basic example to work in the  
console - when I attempt to read the result, I get nil. Can anyone  
spot what may be wrong:

class ReverseWorker < BackgrounDRb::MetaWorker
   set_worker_name :reverse_worker
   def create(args = nil)
     # this method is called, when worker is loaded for the first time
   end

   def reverse(arg = 'missing')
     @result = arg.reverse
   end

   def result
     @result
   end
end

flake:zendesk morten$ script/console
Loading development environment (Rails 2.0.2)
 >> key = MiddleMan.new_worker(:worker => :reverse_worker, :job_key =>  
'123')
{:type=>:start_worker, :worker=>:reverse_worker, :job_key=>"123"}

=> "123"
 >> MiddleMan.worker(:reverse_worker, key).reverse('Hello')
{:type 
= 
 > 
:do_work 
, :data 
= 
 > 
"Hello 
", :worker=>:reverse_worker, :worker_method=>:reverse, :job_key=>"123"}

=> nil
 >> MiddleMan.worker(:reverse_worker, key).result
{:type 
= 
 > 
:do_work 
, :worker=>:reverse_worker, :worker_method=>:result, :job_key=>"123"}

=> nil

Odd isn't it? The debug log:

00000006:	type:start_worker:
                                   worker:reverse_worker:
                                                         job_key123
{:type=>:start_worker, :job_key=>"123", :worker=>:reverse_worker}
00000009{
:	type:
              do_work:	data"
Hello:
       worker:reverse_worker:worker_method:
                                           reverse:
                                                   job_key123
{:type 
= 
 > 
:do_work 
, :job_key 
= 
 > 
"123 
", :worker_method=>:reverse, :worker=>:reverse_worker, :data=>"Hello"}
00000008{	:	type:
                              do_work:
                                       
worker:reverse_worker:worker_method:
                                                                          result 
:
                                                                                 job_key123
{:type 
= 
 > 
:do_work 
, :job_key=>"123", :worker_method=>:result, :worker=>:reverse_worker}

Br,

Morten








More information about the Backgroundrb-devel mailing list