<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><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">www.dryblis.com</a></div><div><br><div><div>On Mar 12, 2009, at 9:22 PM, Justin Wood wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">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">logger.info</a>("Args: #{args}")<br> end<br><br> def send_warranty_notice(data)<br> <a href="http://logger.info">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/">http://backgroundrb.rubyforge.org/workers/</a> the following text <br> <pre class="boxed">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> _______________________________________________<br>Backgroundrb-devel mailing list<br><a href="mailto:Backgroundrb-devel@rubyforge.org">Backgroundrb-devel@rubyforge.org</a><br>http://rubyforge.org/mailman/listinfo/backgroundrb-devel</blockquote></div><br></div></body></html>