Here's the usage
When creating a worker the :create method gets called with args you pass this in with the :data argument to new_worker

MiddleMan.new_worker( :worker => :notification_worker, :worker_key => 'test', :data => "some argument" )

a bit confusing on the names but it is documented. The create method says args even though you pass it in as data

When sending args to your method after you worker is created use something like

MiddleMan.worker( :notification_worker, 'test').enq_some_task( :arg => "some argument" )

Hope that helps

Samer Masry
www.dryblis.com

On Mar 12, 2009, at 9:22 PM, Justin Wood wrote:

Hi, All

It appears that when you enque a task, backgroundrb doesn't pass the "arg" parameter when running the enqued method.

This is my worker:

class NotificationWorker < BackgrounDRb::MetaWorker
  set_worker_name :notification_worker

 def create(args = nil)
   logger.info("Args: #{args}")
 end

  def send_warranty_notice(data)
      logger.info "Sending warranty notice id is #{data}"
  end
end

Here's how I call it from IRB

MiddleMan .worker (:notification_worker ).enq_send_warranty_notice (:arg=>"asdf",:job_key=>Time.now.to_s,:scheduled_at => Time.now + 3.seconds)

The "send_warranty_notice" method gets called but the parameter passed (data) is nil.


Calling async_method works fine:

MiddleMan .worker(:notification_worker).async_send_warranty_notice(:arg=>"asdf")

prints out "Sending warranty notice id is asdf" in the drb log.

Also I noticed that on the following page http://backgroundrb.rubyforge.org/workers/ the following text MiddleMan(:hello_worker).enq_some_task(:arg => "hello_world",:job_key => "boy")

should read

MiddleMan.worker(:hello_worker).enq_some_task(:arg => "hello_world",:job_key => "boy") ... unless I am missing something?



Any suggestions on how I can fix the arg passing problem?


Regards
Justin Wood






_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel

_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel

Reply via email to