Threading in ruby/rails

Hi
I have succesfully send mail from my rails application…I did it like
below.What I am doing is send a mail to an assignee.
def after_transfer
code--------
code------
send_mail_to_primary_assignee(assignee_id)
end

#This is the function responsible for sending mails
def send_mail_to_primary_assignee(contact_id)
contact_name=Contact.find(contact_id).name
official_email_ids =
ContactEmailAddress.find_all_by_contact_id(contact_id ,:conditions =>
“contact_email_address_type_id = ‘2’” )
official_email_ids.each do |official_email|
ServiceDeskMailer.deliver_to_send_mail_to_primary_assignee_on_transfer_reason(official_email,contact_name)
end
puts "```````````````````` "
end

Then my question is how can i put this to seperate thread in ruby…Why I
am asking this is only after all the mails are send i can continue in
the view…So if I put this to a thread is that problem solved .Since I
am new thread especially in ruby could you please tell me how i can
implement that?

Thanks in advance
Sijo

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 10 June 2008 08:42:23 Sijo Kg wrote:

Then my question is how can i put this to seperate thread in
ruby…Why I am asking this is only after all the mails are send i can
continue in the view…So if I put this to a thread  is that problem
solved .

Not really – you just push the problem further down the request chain.
Your request handler can’t complete and pick up a new request until the
mail handling thread completes. In production, this will probably be
unacceptable.

Search the Google Group for backgroundrb, starfish and a4r. This has
been discussed here at least twice in the last week. :slight_smile:

Ciao,
Sheldon.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD4DBQFITksDpGJX8XSgas0RAngkAJMGAbxxlkZZWopd0h90CnNZXsqjAJ9Mpr+3
/uZaCIPYN3VPphqxnhdttQ==
=oZss
-----END PGP SIGNATURE-----

Hi
Thanks for your reply…Meanwhile I was trying with BackGroundrb
pluggin installed like
script/plugin install svn://rubyforge.org//var/svn/backgroundrb

But getting error when trying to start that
[sijo@sijo backgroundrb]$ ./start
./…/…/config/…/lib/workers/billing_worker.rb:6: undefined method
set_worker_ name' for BillingWorker:Class (NoMethodError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_o
riginal_require’
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in requi re' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/ dependencies.rb:495:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/
dependencies.rb:342:in new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/ dependencies.rb:495:inrequire’
from ./start:72
from ./start:72:in `each’
from ./start:72

What might be the reason

Thanks in advance
Sijo

Hi
I here again tried installing Backgroundrb like
svn co http://svn.devjavu.com/backgroundrb/tags/release-0.2.1
/vendor/plugins/backgroundrb

And succed.But now when i did
ruby script/backgroundrb start
It gives the error
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require': no such file to load -- daemons (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
from
/home/sijo/railsexamples/mailexamples/mailing/vendor/plugins/backgroundrb/server/lib/backgroundrb_server.rb:2
from script/backgroundrb:27:in `require’
from script/backgroundrb:27

Could you please tell me what the reason is?

Sijo

Not sure if this is it, but it seems to be saying there’s a gem called
daemons missing?

sudo gem install daemons

On Tue, Jun 10, 2008 at 7:19 PM, Sijo Kg
[email protected] wrote:

`gem_original_require’: no such file to load – daemons (LoadError)

Posted via http://www.ruby-forum.com/.


Ramon T.

On Tue, Jun 10, 2008 at 4:49 PM, Sijo Kg
[email protected] wrote:

gem_original_require': no such file to load -- daemons (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
from
/home/sijo/railsexamples/mailexamples/mailing/vendor/plugins/backgroundrb/server/lib/backgroundrb_server.rb:2
from script/backgroundrb:27:in `require’
from script/backgroundrb:27

Could you please tell me what the reason is?

Any reasons for using such an ancient version of backgroundrb?

Checkout:

http://backgroundrb.rubyforge.org

Also, i am getting backgroundrb for a new release and instructions for
running code from git is here:

http://gnufied.org/2008/05/21/bleeding-edge-version-of-backgroundrb-for-better-memory-usage/

Mant find git version much more stable than svn, so please try that
other than anything else. Also, there is a mailing list for
backgroundrb, which you can use for posting queries.