[Backgroundrb-devel] enq_method doesn't pass 'arg'

Justin Wood justin.wood at trifectagis.com
Fri Mar 13 02:27:05 EDT 2009


Hi, Samer

Thanks for the quick reply.   I changed things a bit and ran this

>>
MiddleMan.new_worker(:worker=>:notification_worker,:worker_key=>'testkey',:data=>"data
arguement")
=> "testkey"
>>
MiddleMan.worker(:notification_worker,'testkey').enq_send_warranty_notice(:job_key=>Time.now.to_s,:arg
=> "asdf",:scheduled_at => Time.now + 3.second)
=> true

... but the arg is still not being passed.

My understanding of new_worker is it explictly creates a worker for you that
you can refer to by the key, so

If I do this:

      MiddleMan.worker(:notification_worker,'testkey')

I'm getting the worker I created above but when I call this:

     MiddleMan.worker(:notification_worker)

I'm getting the default worker that was created at startup.

Regardless of how the worker is created the "arg" parameter is still not
being passed when it gets invoked to do enqued work.   Going through the
code ... I can't figure out how it gets invoked.

Thanks
Justin





On Fri, Mar 13, 2009 at 5:55 PM, Samer Masry <enzodm at gmail.com> wrote:

> 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
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20090313/8659213c/attachment-0001.html>


More information about the Backgroundrb-devel mailing list