Hi, Samer<br><br>Thanks for the quick reply. I changed things a bit and ran this<br><br>>> MiddleMan.new_worker(:worker=>:notification_worker,:worker_key=>'testkey',:data=>"data arguement") <br>
=> "testkey"<br>>> MiddleMan.worker(:notification_worker,'testkey').enq_send_warranty_notice(:job_key=>Time.now.to_s,:arg => "asdf",:scheduled_at => Time.now + 3.second)<br>=> true<br>
<br>... but the arg is still not being passed.<br><br>My understanding of new_worker is it explictly creates a worker for you that you can refer to by the key, so <br><br>If I do this:<br><br> MiddleMan.worker(:notification_worker,'testkey') <br>
<br>I'm getting the worker I created above but when I call this:<br><br> MiddleMan.worker(:notification_worker)<br><br>I'm getting the default worker that was created at startup.<br><br>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.<br>
<br>Thanks<br>Justin<br><br><br><br><br><br><div class="gmail_quote">On Fri, Mar 13, 2009 at 5:55 PM, Samer Masry <span dir="ltr"><<a href="mailto:enzodm@gmail.com">enzodm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div>Here's the usage</div><div>When creating a worker the :create method gets called with args you pass this in with the :data argument to new_worker</div><div><br></div><div>MiddleMan.new_worker( :worker => :notification_worker, :worker_key => 'test', :data => "some argument" )</div>
<div><br></div><div>a bit confusing on the names but it is documented. The create method says args even though you pass it in as data</div><div><br></div><div>When sending args to your method after you worker is created use something like</div>
<div><br></div><div>MiddleMan.worker( :notification_worker, 'test').enq_some_task( :arg => "some argument" )</div><div><br></div>Hope that helps<div><br></div><div>Samer Masry</div><div><a href="http://www.dryblis.com" target="_blank">www.dryblis.com</a></div>
<div><br><div><div><div></div><div class="h5"><div>On Mar 12, 2009, at 9:22 PM, Justin Wood wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">Hi, All<br><br>It appears that when you enque a task, backgroundrb doesn't pass the "arg" parameter when running the enqued method.<br>
<br>This is my worker:<br><br>class NotificationWorker < BackgrounDRb::MetaWorker<br> set_worker_name :notification_worker<br><br> def create(args = nil)<br> <a href="http://logger.info" target="_blank">logger.info</a>("Args: #{args}")<br>
end<br><br> def send_warranty_notice(data)<br> <a href="http://logger.info" target="_blank">logger.info</a> "Sending warranty notice id is #{data}"<br> end<br>end<br><br>Here's how I call it from IRB<br>
<br>MiddleMan.worker(:notification_worker).enq_send_warranty_notice(:arg=>"asdf",:job_key=>Time.now.to_s,:scheduled_at => Time.now + 3.seconds)<br> <br>The "send_warranty_notice" method gets called but the parameter passed (data) is nil.<br>
<br><br>Calling async_method works fine:<br><br>MiddleMan.worker(:notification_worker).async_send_warranty_notice(:arg=>"asdf")<br> <br>prints out "Sending warranty notice id is asdf" in the drb log.<br>
<br>Also I noticed that on the following page <a href="http://backgroundrb.rubyforge.org/workers/" target="_blank">http://backgroundrb.rubyforge.org/workers/</a> the following text <br> <pre>MiddleMan(:hello_worker).enq_some_task(:arg => "hello_world",:job_key => "boy")<br>
<br>should read<br><br>MiddleMan.worker(:hello_worker).enq_some_task(:arg => "hello_world",:job_key => "boy") ... unless I am missing something?<br>
<br><br>Any suggestions on how I can fix the arg passing problem?<br><br><br>Regards<br>Justin Wood<br><br><br><br></pre><br><br><br></div></div> _______________________________________________<br>Backgroundrb-devel mailing list<br>
<a href="mailto:Backgroundrb-devel@rubyforge.org" target="_blank">Backgroundrb-devel@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/backgroundrb-devel" target="_blank">http://rubyforge.org/mailman/listinfo/backgroundrb-devel</a></blockquote>
</div><br></div></div></blockquote></div><br>