[Backgroundrb-devel] Problem passing multiple arguments as hash to enq_method

Chris Johnson wchrisjohnson at gmail.com
Tue May 12 19:23:01 EDT 2009


Hi,

I'm having trouble calling the enq_* method on my worker and passing  
in multiple arguments via hash. I CAN pass in an an array of arguments  
and it works; but the hash syntax does not seem to work.

My worker is loaded automatically when the BDRB process is started.


This works:

WORKER:
-----------------------------------------------------------------------------
class ReportingWorker < BackgrounDRb::MetaWorker
  set_worker_name :reporting_worker
  set_no_auto_load false

  def create(args=nil)
    logger.info "ReportingWorker started."
  end

  def create_export(args)
    work_order_id = args[0]
    user_id = args[1]
    .... # do stuff
  end # create_export

end


SCRIPT/CONSOLE

MiddleMan.worker(:reporting_worker). create_export(:arg =>  
[2887,1], :job_key => 2887, :scheduled_at => Time.now)
-----------------------------------------------------------------------------


This does not work:

WORKER:
-----------------------------------------------------------------------------
class ReportingWorker < BackgrounDRb::MetaWorker
  set_worker_name :reporting_worker
  set_no_auto_load false

  def create(args=nil)
    logger.info "ReportingWorker started."
  end

  def create_export(args)
    work_order_id = args["work_order_id"]
    user_id = args["user_id"]
    .... # do stuff
  end # create_export

end

SCRIPT/CONSOLE

MiddleMan.worker(:reporting_worker). create_export(:arg =>  
[{:work_order_id => 2887, :user_id => 1}], :job_key =>  
2887, :scheduled_at => Time.now)
MiddleMan.worker(:reporting_worker). create_export(:arg =>  
{:work_order_id => 2887, :user_id => 1}, :job_key =>  
2887, :scheduled_at => Time.now)

(neither works)
-----------------------------------------------------------------------------




I should also note that I'm currently using the async_* technique to  
kick off these report jobs (similar to the FIRST example noted above)  
and that works OK; I WOULD like to be able to track jobs via the queue  
though; hence my desire to get this enq_* stuff working consistently.


Thanks in advance for any help!

Chris


More information about the Backgroundrb-devel mailing list