I''m working on upgrading my app to the latest version of backgroundrb. Everything went find until I tried to execute my tasks. Here is my simple worker for testing: class MscWorker < BackgrounDRb::MetaWorker set_worker_name :msc_worker def create(args = nil) # this method is called, when worker is loaded for the first time end # Send a message to everyone def send_message_to_all(args = nil) Message.send_to_everyone(args[:sender], args[:subject], args[:body], false) rescue logger.error "MscWorker - #{err.class}: #{err}" end end Called like so: MiddleMan.ask_work(:worker => :msc_worker, :worker_method => :send_message_to_all, :data => { :sender => sender, :subject => subject, :body => body }) I get lots of errors starting with this: /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in `load'': undefined class/module User (ArgumentError) I tried to require the classes in my worker file, and that will make some errors go away, but it looks to want EVERY possible rails class or my model required. Something doesn''t seem right here. What do I need to do to use my models? Piston says I''m on revision 293. -- Dave Dupre -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071221/246d647e/attachment.html
On Dec 21, 2007 9:14 AM, Dave Dupre <gobigdave at gmail.com> wrote:> I''m working on upgrading my app to the latest version of backgroundrb. > Everything went find until I tried to execute my tasks. > > Here is my simple worker for testing: > > class MscWorker < BackgrounDRb::MetaWorker > set_worker_name :msc_worker > def create(args = nil) > # this method is called, when worker is loaded for the first time > end > # Send a message to everyone > def send_message_to_all(args = nil) > Message.send_to_everyone(args[:sender], args[:subject], args[:body], > false) > rescue > logger.error "MscWorker - #{err.class}: #{err}" > end > end > > Called like so: > MiddleMan.ask_work(:worker => :msc_worker, :worker_method => > :send_message_to_all, :data => { :sender => sender, :subject => subject, > :body => body }) > > I get lots of errors starting with this: > /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in > `load'': undefined class/module User (ArgumentError)I''m taking a wild guess here, but I think the problem may be in sending a user object to your worker via MiddleMan. Instead of using "sender", maybe try { :sender_id => sender.id } and in your worker look up the sender (i.e. sender = User.find(sender_id) ). - Jason L. -- My Rails and Linux Blog: http://offtheline.net
That was it! Now that I think of it, I think I made the same mistake with the old version as well. Thanks! Now I can add the rest of my jobs. Dave On Dec 21, 2007 12:48 PM, Jason LaPier <jason.lapier at gmail.com> wrote:> On Dec 21, 2007 9:14 AM, Dave Dupre <gobigdave at gmail.com> wrote: > > I''m working on upgrading my app to the latest version of backgroundrb. > > Everything went find until I tried to execute my tasks. > > > > Here is my simple worker for testing: > > > > class MscWorker < BackgrounDRb::MetaWorker > > set_worker_name :msc_worker > > def create(args = nil) > > # this method is called, when worker is loaded for the first time > > end > > # Send a message to everyone > > def send_message_to_all(args = nil) > > Message.send_to_everyone(args[:sender], args[:subject], args[:body], > > false) > > rescue > > logger.error "MscWorker - #{err.class}: #{err}" > > end > > end > > > > Called like so: > > MiddleMan.ask_work(:worker => :msc_worker, :worker_method => > > :send_message_to_all, :data => { :sender => sender, :subject => subject, > > :body => body }) > > > > I get lots of errors starting with this: > > > /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in > > `load'': undefined class/module User (ArgumentError) > > I''m taking a wild guess here, but I think the problem may be in > sending a user object to your worker via MiddleMan. Instead of using > "sender", maybe try { :sender_id => sender.id } and in your worker > look up the sender (i.e. sender = User.find(sender_id) ). > > - Jason L. > > > > -- > My Rails and Linux Blog: http://offtheline.net > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel >-- Dave Dupre (m) 617-921-1684 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071221/95df9562/attachment.html
Maybe I spoke to soon. Everything works every time, but after the first time I run it, "Some read error" shows up in the command prompt. This is only when called like: script/backrgoundrb There is nothing in the logs that shows an error. Again, the job works every time. Not a big deal since I will not be running it this way in production anyway. Just an FYI... Dave On Dec 21, 2007 1:36 PM, Dave Dupre <gobigdave at gmail.com> wrote:> That was it! Now that I think of it, I think I made the same mistake with > the old version as well. > > Thanks! Now I can add the rest of my jobs. > > Dave > > > On Dec 21, 2007 12:48 PM, Jason LaPier <jason.lapier at gmail.com> wrote: > > > On Dec 21, 2007 9:14 AM, Dave Dupre <gobigdave at gmail.com> wrote: > > > I''m working on upgrading my app to the latest version of backgroundrb. > > > > > Everything went find until I tried to execute my tasks. > > > > > > Here is my simple worker for testing: > > > > > > class MscWorker < BackgrounDRb::MetaWorker > > > set_worker_name :msc_worker > > > def create(args = nil) > > > # this method is called, when worker is loaded for the first time > > > end > > > # Send a message to everyone > > > def send_message_to_all(args = nil) > > > Message.send_to_everyone (args[:sender], args[:subject], > > args[:body], > > > false) > > > rescue > > > logger.error "MscWorker - #{err.class}: #{err}" > > > end > > > end > > > > > > Called like so: > > > MiddleMan.ask_work (:worker => :msc_worker, :worker_method => > > > :send_message_to_all, :data => { :sender => sender, :subject => > > subject, > > > :body => body }) > > > > > > I get lots of errors starting with this: > > > > > /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in > > > `load'': undefined class/module User (ArgumentError) > > > > I''m taking a wild guess here, but I think the problem may be in > > sending a user object to your worker via MiddleMan. Instead of using > > "sender", maybe try { :sender_id => sender.id } and in your worker > > look up the sender ( i.e. sender = User.find(sender_id) ). > > > > - Jason L. > > > > > > > > -- > > My Rails and Linux Blog: http://offtheline.net > > _______________________________________________ > > Backgroundrb-devel mailing list > > Backgroundrb-devel at rubyforge.org > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > > > -- > Dave Dupre > (m) 617-921-1684-- Dave Dupre (m) 617-921-1684 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071221/7bf8f785/attachment.html
According to hemant, those "some read errors" are in there for debugging and not actually a fatal error; they just represent opening/closing connection between rails and the worker: http://rubyforge.org/pipermail/backgroundrb-devel/2007-December/001169.html So if it works, you don''t have to worry about those errors. - Jason L. On Dec 21, 2007 10:48 AM, Dave Dupre <gobigdave at gmail.com> wrote:> Maybe I spoke to soon. Everything works every time, but after the first > time I run it, "Some read error" shows up in the command prompt. This is > only when called like: > > script/backrgoundrb > > There is nothing in the logs that shows an error. Again, the job works > every time. > > Not a big deal since I will not be running it this way in production anyway. > Just an FYI... > > Dave > > > > On Dec 21, 2007 1:36 PM, Dave Dupre < gobigdave at gmail.com> wrote: > > That was it! Now that I think of it, I think I made the same mistake with > the old version as well. > > > > Thanks! Now I can add the rest of my jobs. > > > > Dave > > > > > > > > > > > > On Dec 21, 2007 12:48 PM, Jason LaPier <jason.lapier at gmail.com> wrote: > > > > > > > > On Dec 21, 2007 9:14 AM, Dave Dupre <gobigdave at gmail.com> wrote: > > > > > > > I''m working on upgrading my app to the latest version of backgroundrb. > > > > Everything went find until I tried to execute my tasks. > > > > > > > > Here is my simple worker for testing: > > > > > > > > class MscWorker < BackgrounDRb::MetaWorker > > > > set_worker_name :msc_worker > > > > def create(args = nil) > > > > # this method is called, when worker is loaded for the first time > > > > end > > > > # Send a message to everyone > > > > def send_message_to_all(args = nil) > > > > Message.send_to_everyone (args[:sender], args[:subject], > args[:body], > > > > false) > > > > rescue > > > > logger.error "MscWorker - #{err.class}: #{err}" > > > > end > > > > end > > > > > > > > Called like so: > > > > MiddleMan.ask_work (:worker => :msc_worker, :worker_method => > > > > :send_message_to_all, :data => { :sender => sender, :subject => > subject, > > > > :body => body }) > > > > > > > > I get lots of errors starting with this: > > > > > /Users/dave/projects/backgroundrb1.0_msc/vendor/plugins/backgroundrb/server/master_worker.rb:31:in > > > > `load'': undefined class/module User (ArgumentError) > > > > > > > > > I''m taking a wild guess here, but I think the problem may be in > > > sending a user object to your worker via MiddleMan. Instead of using > > > "sender", maybe try { :sender_id => sender.id } and in your worker > > > look up the sender ( i.e. sender = User.find(sender_id) ). > > > > > > - Jason L. > > > > > > > > > > > > -- > > > My Rails and Linux Blog: http://offtheline.net > > > _______________________________________________ > > > Backgroundrb-devel mailing list > > > Backgroundrb-devel at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/backgroundrb-devel > > > > > > > > > > > -- > > Dave Dupre > > (m) 617-921-1684 > > > > -- > Dave Dupre > (m) 617-921-1684-- My Rails and Linux Blog: http://offtheline.net
On Dec 22, 2007 12:24 AM, Jason LaPier <jason.lapier at gmail.com> wrote:> According to hemant, those "some read errors" are in there for > debugging and not actually a fatal error; they just represent > opening/closing connection between rails and the worker: > http://rubyforge.org/pipermail/backgroundrb-devel/2007-December/001169.html >Yes, don''t worry about the log message. It has been removed from trunk anyways. Also, if you sync with trunk you now have the capability to pass model objects directly to BackgrounDRb workers. Its still not advisable, since model objects are generally complex objects and they contain class hierarchies, and marhalling them across wire and constructing them back at other end is tricky business. But you have the capability so use with care, only pass simple models around if you must. There are other important fixes as well, so upgrade now. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
Hello, I recently upgraded to the new backgroundrb. I noticed that the "get_worker" method is gone. I am trying to create multiple instances of the same worker and retrieve the status of them using the job key: To create the worker, I do: @worker = MiddleMan.new_worker(:worker => :bar_worker, :worker_method => :echo_value, :job_key => @job_key, :data => {:param1 => ''val1'',:param2 => ''val2'' }) To retrieve the worker, I have tried: @worker = MiddleMan.ask_status(:worker => :bar_worker, :job_key => @job_key) but it does not work. I used to be able to do this with get_worker. Can someone explain how to use this feature with the new version? Kevin English
On Fri, 2007-12-21 at 09:51 -1000, Kevin W. English wrote:> Hello, I recently upgraded to the new backgroundrb. I noticed that the > "get_worker" method is gone. I am trying to create multiple instances of > the same worker and retrieve the status of them using the job key: > > To create the worker, I do: > > @worker = MiddleMan.new_worker(:worker => :bar_worker, > :worker_method => :echo_value, > :job_key => @job_key, > :data => {:param1 => ''val1'',:param2 => ''val2'' }) > > > To retrieve the worker, I have tried: > > @worker = MiddleMan.ask_status(:worker => :bar_worker, :job_key => > @job_key) > > but it does not work. I used to be able to do this with get_worker. Can > someone explain how to use this feature with the new version? >What happens, you get an error? Ok, You must register status of your worker before able to retrieve it using ask_status. By default, all workers start with a status of nil. So, make sure that in worker code, you are using register_status() to register current status of worker.