[Backgroundrb-devel] 1) Error 2) sending request to a specific worker

Mickael Faivre-Macon faivrem at gmail.com
Sat Dec 15 18:12:12 EST 2007


Hi hemant,

Thanks for your reply.

The reason why I don't see the advantage to let the worker start wiht
bdrb may be related to my understanding of how it works, and
specifically to my question about keys and specific worker instances.

I am using bdrb to keeps connections to a XMPP (Jabber) server, while
Rails renders the UI (web based chat application). So the way I see
it, is that there is only one :xmpp_worker class but several instances
of that class running, each with a specific login and connection to
the Jabber server.

That's why I am launching a new :xmpp_worker (for each chat user).
And that's why I need to know how to send_request (or ask_work) to a
specific worker instance. I thought it could be done with the concept
of keys.

Is that the right way of doing things ?
How would you do it ?

Thanks,
Mickael.


On Dec 15, 2007 11:43 PM, hemant <gethemant at gmail.com> wrote:
>
> On Dec 16, 2007 3:38 AM, Mickael Faivre-Macon <faivrem at gmail.com> wrote:
> > Hello !
> >
> > 1) I have this error logged by bdrb:
> > undefined method `send_request' for nil:NilClass
> > framework/packet_master.rb:58:in `ask_worker'
> > backgroundrb/server/master_worker.rb:59:in `process_work'
> > backgroundrb/server/master_worker.rb:16:in `receive_data'
> > backgroundrb/framework/bin_parser.rb:29:in `call'
> > backgroundrb/framework/bin_parser.rb:29:in `extract'
> > backgroundrb/server/master_worker.rb:12:in `receive_data'
> > backgroundrb/framework/core.rb:191:in `read_external_socket'
> > backgroundrb/framework/core.rb:183:in `handle_external_messages'
> > backgroundrb/framework/core.rb:156:in `start_reactor'
> > backgroundrb/framework/core.rb:152:in `each'
> > backgroundrb/framework/core.rb:152:in `start_reactor'
> > backgroundrb/framework/core.rb:144:in `loop'
> > backgroundrb/framework/core.rb:144:in `start_reactor'
> > backgroundrb/framework/packet_master.rb:20:in `run'
> > backgroundrb/server/master_worker.rb:115:in `initialize'
> > ./script/backgroundrb:39:in `new'
> > ./script/backgroundrb:39
> >
> > my code is :
> >
> > class MyController < ApplicationController
> >
> >   def index
> >   end
> >
> >   def login
> >     @worker = MiddleMan.new_worker(:worker => :xmpp_worker, :job_key => :my_key)
> >     MiddleMan.ask_work(:worker => :xmpp_worker, :worker_method =>
> > :login, :data => "test")
> >     render(:partial=>'window')
> >   end
> >
> > end
> >
> > class XmppWorker < BackgrounDRb::MetaWorker
> >   set_worker_name :xmpp_worker
> >   set_no_auto_load true
> >
> >   def create(args = nil)
> >   end
> >
> >   def login
> >   end
> >
> > end
> >
> > Can someone helps me ?
> >
> > 2) I am creating a worker with a key : MiddleMan.new_worker(:worker =>
> > :xmpp_worker, :job_key => :my_key)
> > Is it possible to use this key in a request to send work to a specific worker ?
> >
>
> I suggest you remove set_no_auto_load(true). Why exactly, you don't
> want worker to be automatically loaded when bdrb starts?
>
> The problem as i see may be because, since new_worker forks new worker
> in separate process, but the worker is not available immediately and
> hence you get the error.
>
> If you insist on using dynamically starting workers, I will be see
> what can be done to prevent error. There are couple of options.


More information about the Backgroundrb-devel mailing list